UITableView reloadData calls UITextField for resignFirstResponder

I have a textField that is configured to change the dataView of the tableView source with each letter entered (and calls reloadData).

But for some reason, every time a letter is entered, the keyboard is rejected.

Does anyone know why?

+7
source share
2 answers

Your text box resigns because reloaded cells are sent to the -resignFirstResponder message because their survival is not guaranteed after a reboot. See this for more information.

+10
source

Use this textFieldShouldReturn: method and add the UITextFieldDelegate delegate to yourClass.h. set the delegate to yourTextfield and write the following code in the viewDidLoad method.

yourTextfield.delegate = self;

and also implement textFieldShouldReturn: as follows:

 - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { [theTextField resignFirstResponder]; return YES; } 

I think it will be useful for you.

-3
source

All Articles