Reputation: 2488
In my app i'm using a UITextField
collect a string value. Whenever i finish editing the field, textFieldDidEndEditing
gets fired, but later textFieldShouldReturn
never. What can be it's reason?
I provide some code:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if(textField == self.urlPatternTextField) {
/*do some stuff*/
}
}
- (IBAction)dismissKeyboard:(id)sender {
NSMutableArray* possibleReponders = [[NSMutableArray alloc]initWithObjects:
self.urlPatternTextField, nil];
for (UITextView* tv in possibleReponders) {
if([tv isFirstResponder]) {
[tv resignFirstResponder];
return;
}
}
}
Note:
In textFieldDidEndEditing the if condition is true.
Thanks for the help in advance.
Sincerely,
Zoli
Upvotes: 0
Views: 3358
Reputation: 20021
textFieldShouldReturn:
Asks the delegate if the text field should process the pressing of the return button.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
Parameters
textField The text field whose return button was pressed.
Return Value YES if the text field should implement its default behavior for the return button; otherwise, NO.
Discussion The text field calls this method whenever the user taps the return button. You can use this method to implement any custom behavior when the button is tapped.
The method invokes when return button is pressed.Try it so
Upvotes: 1