How do I programmatically set the Return Key for a particular UITextField?
I can’t believe that this question hasn’t been asked yet, but I have been unable to find it so that is my assumption.
I have created custom
UITableViewCell subclasses using Interface Builder. These each contain a
UILabel and a
UITextField and are used for our login screen.
On the first
UITextField, I want the Keyboard Key to say
Next. However, on the second
UITextField, I want it to say “Done.”
How do I programmatically change the value of the
Return Key on the keyboard? I cannot use
Interface Builder, since that would make both keys appear as
- Is it necessary to assign a string to a variable before comparing it to another?
- Adding tool bar on top of the uikeyboard
- Navigation bar gets adjusted after calling completeTransition: in custom transition
- Can't insert object in the array, that I want add to User Defaults
- Input from UITextField connected from storyboard to Swift view controller file
- How to hide the keyboard when i press return key in a UITextField?
2 Solutions Collect From Internet About “How do I programmatically set the Return Key for a particular UITextField?”
For the first
UITextField, Read THIS tutorial on how to create a button on a Keyboard. You can learn the logic from there and use a
Next button instead of
//if you just want to make it appear NEXT// textField.returnKeyType = UIReturnKeyNext;
And for the second
// for DONE // textField.returnKeyType = UIReturnKeyDone;
You can in general create and rename the button to anything, and make sure you give the right
IBAction on the event that that button is pressed. In case you do create your own custom button, look at the tutorial above to learn about placing it in the right coordinates and stuff.
It can also be done by setting property in .xib file. You just have to set
Return Key property of
- iPhone – Debugging a crash when you can't find it
- CATiledLayer in iPad retina simulator yields poor performance
- What is the Label property under the identity inspector in Xcode 4?
- IOS app killed for Low Memory but no Memory Warning received
- RestKit and saving to CoreData as NSManagedObject
- How to change PFUser password in Swift?
- Xcode 5: Unit Tests not running
- UIView hidden property…is there more to it?
- iOS simulator for iPhone 5- 1136 x 640 resolution
- Ambiguous reference to member 'tableView'
- Text Field Should Return, is this correct for ios7?
- How do I set title for UIBarButtonItem?
- Why print() is printing my String as an optional?
- Animating custom-drawn UITableViewCell when entering edit mode
- Reload UICollectionViewCell which has image