I have UITextField inside a UITableView. I’ve set the delegate of the text view in the cellForRowAtIndexPath method of my UITableView as follows
cell.textField.delegate = self;
but when I finished editing and press “done” I didn’t get anything in my delegate method as shown below. What could be the reason?
-(void) textFieldDidEndEditing: (UITextField * ) textField {
NSLog(@"here");
}
The
textFieldDidEndEditing:method is called after the text field resigns first responder status. To get the text field to resign first responder status, send it aresignFirstRespondermessage. A good place to do that is in the text field delegate’stextFieldShouldReturn:method. It would look something like this:When the user taps the “Done” key, the
textFieldShouldReturn:method will get called, causing the text field to resign first responder status andtextFieldDidEndEditing:to be called.