I'm a newbie developing for iOS devices. I inserted an UITextField on InterfaceBuilder, and I assigned with the code:
@interface ComposeViewController : UIViewController { id <ComposeViewControllerDelegate> delegate; IBOutlet UITextField *notificationTitle; }
How I could allow to close the keyboard when the user press the "Return" key?
If you have a UITextField and you want to hide the keyboard when the user is pressing the return key, use the textFieldShouldReturn function. Be sure you have set the textField. delegate = self in your viewDidLoad() function.
Microsoft SwiftKey does not have a dedicated minimize keyboard button. Instead, if you slide a finger down the keys from top to bottom, your Microsoft SwiftKey Keyboard is minimized.
You can ask the system to dismiss the keyboard by calling the resignFirstResponder method of your text field. Usually, you dismiss the keyboard in response to specific interactions. For example, you might dismiss the keyboard when the user taps the keyboard's return key.
The UITextField's inputView property is nil by default, which means the standard keyboard gets displayed. If you want to hide both the keyboard and the blinking cursor then use this approach: -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField { return NO; // Hide both keyboard and blinking cursor. }
Set the Delegate of the UITextField to your ViewController, add a referencing outlet between the File's Owner and the UITextField, then implement this method:
- (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == yourTextField) { [textField resignFirstResponder]; } return NO; }
Inherit UITextFieldDelegate protocol In viewDidLoad method set:
yourTextField.delegate = self
Implement the delegate method below: - (BOOL)textFieldShouldReturn:(UITextField *)textField { [yourTextField resignFirstResponder]; return NO; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With