开发者

how do we keep the keyboard rather than dismissing it using UITextField textFieldShouldReturn?

I want to keep my keyboard up after I input something since I am gathering up multiple answers for one question.

So far I am calling:

- (BOOL)textFieldShouldReturn:(UITextFi开发者_Go百科eld*)textField {
  [textField resignFirstResponder];
  return YES;
}

But when remove resignFirstResponder, I am not getting any response for my input handler on this method:

- (void)textFieldDidEndEditing:(UITextField*)textField;

Anyone have an idea on how to deal with this?


Found my solution, in my

- (void)textFieldDidEndEditing:(UITextField*)textField;

I just make the textField back to first responder after it has been resigned:

[textField becomeFirstResponder];


Thanks for posting your reply, it got me pointed in the right direction. I found what I think is an easier solution:

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    return NO; // Don't hide keyboard
}

// Use "did end on exit" instead of "did end" since "did end" won't get fired
- (IBAction)textViewDidEndOnExit{
    // Do stuff here...
}

If you return NO from textFieldShouldEndEditing you don't need to call becomeFirstResponder afterwards.

(I tried posting this as a comment to your answer, but the code formatting doesn't work there...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜