In order to dismiss keyboard linked to programmatically built UITextField, follow the following steps:

Step 1:
Make sure your view is like below:

@interface PlayView : UIViewController <UITextFieldDelegate> {

Step 2:

userTextField.delegate = self;

The delegate for the dynamically built UITextFIeld should be set to self.

Step 3:

If you want to hide the keyboard in response to "Done" key:

– (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}

Step 4:
If you want to hide keyboard in response to some custom function, use below:
 [textField resignFirstResponder];
textField = Object representing the UITextField.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation