I am in situation where user enters data into UITextField in without resign of keyboard he presses Next button go to next page.
That textfield is in custom cell with UITextView
. Now I want to capture everything in every textfield & UITextView of that UITableView when user enters into it because at time of Next button click I need to save the data.
Till Now I have implemented below methods but none of these getting called when user enters data into TextField and directly press Next button without returning keyboard
- (void)textFieldDidEndEditing:(UITextField *)textField
{
NSString *strTitle = [textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
textField.text = strTitle;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return YES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
What could be the best wat to save from that TextFields before Next?
textFieldDidEndEditing in not always called when you lose the focus. see the post https://stackoverflow.com/a/1229914/641062. It explains a bit about more about the endEditing method's behaviour.
So must save your data in this method. This will called for every character you type.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return YES;
}