UITableViewCell and resignFirstResponder

I have a UITableView contained in every cell of a UITextField . When the user clicks on the UITextField , as expected, the keyboard will pop up.

I used the tableView: didSelectRowAtIndexPath: method in my deletion to reject the keyboard using resignFirstResponder sent to the last UITextField .

Everything works fine if the cell with the last UITextField .

Now, if I scroll the bottom of the table and click on a row, then resignFirstResponder sent to the hidden UITextField and does not hide the keyboard. It also does not cause errors.

How can I hide the keyboard in such cases?

+4
source share
4 answers

Take a look at UITextFieldDelegate and put

 [textField resignFirstResponder]; 

in one of the callback functions. I particularly prefer:

 - (BOOL)textFieldShouldReturn:(UITextField *)textField; 
+4
source

Have you tried calling endEditing:YES UITextField ?

0
source
 -(IBAction)hidekey:(id) sender{ [textField resignFirstResponder]; } 

if you use the interface builder, then check the output of the text field and in the .m file using the function above and define a text field for this. He will work.

0
source

Please use this tutorial to Create a Return Key for UIKeyboardTypeNumberPad ! This should save a lot of time for you.

0
source

All Articles