Checkboxes in Xcode - iphone

What I'm wanting to do is add checkboxes and have a title for each checkbox and have if certain boxes are checked then it displays certain texts like
if box 1, box 2, box 4, and box 5 are selected then displays text1
if box 1 is selected then displays text2
if box 1, box 3, and box 4 are selected then displays text3
Something like that. Help would be appreciated. Thanks.

For the UI use a UiTableViewController with two images one for unchecked and the other for the checked state. Those images are assigned to the UITableViewCell's imageView property.
For checking state, I would store all values into one int field and make a corresponding typedef enum so that i could use a bitwise & to check to see if a value or combination of values is selected.
I could post some code later if needed.

You can use UISwitch controls for a simple on/off control, and UILabel controls for text. You could have a single UILabel whose text changes, or multiple ones and mark them hidden depending on which switches are on.

Related

How can i change the selection of textfield copy paste options

1)Take Input from Text Field and Input will show on bottom of Text field and Input has multiple Words.
2)Long press on single world It will appear a toast with multiple option opy ,paste ,change color .
3)Click on change color option selected Word should be change color .
4)Click on double click It should be redirect with same words.
Add addition menu item using UIMenuController, something like this:
let changeColor = UIMenuItem(title: "Change Color", action: #selector(changeColor:))
UIMenuController.shared.menuItems = [changeColor]
You can make the changes in changeColor function and update textfield's content from there with your color attributes.
Double-tap is used to show menu controller options, changing that may not be straight forward change. You need to explore swizzling to achieve that.

How to set first responder for NSTextView in Swift?

Edit: in a macOS project
I have a simple ViewController which I display as popover on a status item menu app.
I change the text of the view text with a NSTableView, depending of which item is clicked. The code I use is similar to this one:
mainTextField.insertText(newStr, replacementRange: theRange)
(I use insertText for the purpose to have the change recorded in undo manager)
Then I highlight the text:
// create the new NSRange
let range = NSRange(location: startRange, length: newStrLength)
// select the range in field
mainTextField.selectedRange = range
All work fine, except that the text is highlighted but with a light grey instead of the usual sky blue, indicating that the control is not the first responder. And when I click on the field the selection disappear.
Actually I would like that the NSTextView becomes first responder so I can directly copy the selected text.
Edit: if I press Tab key on the keyboard I got the textView to become first responder (and the grey selection becomes standard sky blue).
Corrected Answer
In AppKit, you need:
if mainTextField.acceptsFirstResponder {
mainTextField.window?.makeFirstResponder(mainTextField)
}
In this case, it's probably safe to not check acceptsFirstResponder, but it doesn't hurt either.
Original Answer (UIKit)
You need to call mainTextField.becomeFirstResponder().

Access Form layout and design: Header: How do I make my header section look like Google

I would like to rip off Google's design for my Continuous Form. The detail section of the form is set up to display N number of records resulting from a search, and thus cannot be used to create this effect (i think). Everything must go in the header section.
there are 2 primary issues I would like to address in this question:
Two toned background. The header section should have a grey stripe and a white stripe. This stripe needs to extend the full width of the form, which is variable and will depend on the user. (i'm using tabs not pop-ups)
How to right justify certain elements of the header so that they stay close to the right edge, wherever that may fall, just like your account information on Google.
The "Search Results" in the detail section are loaded by setting the form's recordSource to the results of a query defined in VBA, which takes parameters from the search box. The form is continuous.
Any ideas how to hack this into place?
Recent versions of MS Access provide improved form layout features when using the ACCDB database file format.
The screen captures below are based on a form in Access 2010. The second image is after the form width was expanded, but it's scaled down for display on this web page. However you can open those images directly to compare their relative widths.
The grey color is from the form header's Back Color property. The white box is a simple text box whose Back Color is white and Back Style is Normal (not Transparent).
The text box's Horizontal Anchor property is Both, and its Can Grow property is Yes. The other 3 items ("?", "Button 2", and "Button 3") are command buttons. Their Horizontal Anchors are set to Right and their Can Grow properties are No.
The result of those properties is that when the form expands, those command buttons maintain their size are are kept right-aligned within the form. And the text box stretches to fill the remaining available space.
Note this behavior is accomplished without any VBA code.
I think these layout capabilities were introduced in Access 2007 and perhaps refined in 2010.
For the background, use two rectangles with transparent borders, one back color gray, one white. You can size them to the form by using the form's InsideWidth property. For example:
Private Sub Form_Resize()
rect1.Width = Me.InsideWidth
rect2.Width = Me.InsideWidth
End Sub
I would do a similar thing for the buttons/images/etc you want right justified. Set their Left property relative to the form's width:
mySettingsButton.Left = Me.InsideWidth - 300
Keep in mind all the measurements are twips (1440 twips/inch)

Entering text-data into a Table cell, without having a UITextField in each cell

I would like to let the user fill in some data to be submitted.
So I have a table with 7 cells, each of them are labeled so they know what data goes into the field.
I though about putting a UITextField in each cell, but it looks like its out of place and the user can enter up to 255 chars, so also it doesn't display the data so nicely.
Can anybody recommend a good way to handle this kind of thing, whats the best solution in your experience?
Maybe hiding the UITextField after they are done entering data and display the data in some other manner?
Kind Regards,
-Code
You can customize a UITextField in several different ways to make it not look out of place to you: things such as location, size, alignment, font, font size, background color, and etc. You can have the text field appearance change depending on whether the text field is in the selected table row or not.
You can also have a UITextField delegate pre-check any changes to the text field, and prohibit entering a text length greater than some number of characters, or illegal/unwanted characters, etc.

Objective C - Create Multiple TextFields for the User, then randomly select one and output the Entered Data

Basically what I am trying to do is:
1) The user sets the number of choices he wants e.g. 3 choices which are "A", "B", "C"
[Done this]
2) The next view is loaded and the right amount of boxes are created, 3 in this case. The boxes need to be blank at first and then the user enters their choices into the boxes.
e.g. "A", "B", "C"
Note: I tried create multiple text boxes automatically, but I found that after about 6 boxes the screen wouldn't scroll and therefore looked very tacky
3)At a click of a button, one of the textboxes is selected randomly. The inputed data from this randomly selected box is then displayed in NSLog or Label or file, which i will then use in another view.
Thanks
Dan
Hey, you could make a scrollView out of the 2th view. That way, you can still automatically create textfields, and the screen will scroll. Check out this link for more information on how to create a scrollview. Perhaps you can make the scrollview's size dynamically (depending on how much textfields you have).
About selecting a random textfield, use arc4random() More about that can be found here.