Reputation: 1175
I have a customized UITableViewCell with textfields. The textfields of the cells are set to call for delegate functions. Inside
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
if(textField == fromTF){
fromTF.text = [[[fromTF.text substringToIndex:2] stringByAppendingString:@":"] stringByAppendingString:[fromTF.text substringFromIndex:2]];
[toTF becomeFirstResponder];
return YES;
}
if(textField == toTF){
[toTF resignFirstResponder];
[intTF becomeFirstResponder];
return YES;
}
return YES;
}
This is delegate method is called in my custom cell.However when called, the UIKeyBoardWillHideNotification addobserver object is not removed when pressed 'return' key. Is there a way I can resolve this?
Upvotes: 1
Views: 245
Reputation: 1175
Hello Ganesh thank you for the answer. I removed the resignFirstResponder and passed the firstResponder directly to the next textfield. This prevented the keyboard from disappearing.
Upvotes: 0
Reputation: 2061
Try like this
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}
and also check this link textFieldShouldBeginEditing + UIKeyboardWillShowNotification + OS 3.2
it may help you.
Upvotes: 1