开发者

How to make iphone's keyboard never hide?

I need keyboard never hide in my view (for example as in facebook app in login form)

How can I do it? I use

[textFieldEmail addTarget:self 
                   acti开发者_C百科on:@selector(textFieldDone:) 
         forControlEvents:UIControlEventEditingDidEndOnExit];

and when i tap done on keyboard, it hides, I tried

- (IBAction)textFieldDone:(id)sender {  
[sender becomeFirstResponder];
   //...
}

but it doesn't help, how can i do it?

Thanks


You need to implement the following method of the UITextFieldDelegate:

- (BOOL)textFieldShouldReturn:(UITextField *)textField

Also ensure you have specified the UITextField's delegate.


Remove all that code.

Usually people have the opposite problem - trying to figure out how/when to hide they keyboard!

If you do nothing - by default - the keyboard will stay up! The "done" key should not dismiss the keyboard, unless someone, somewhere is calling "resignFirstResponder".


In order to make a login form as in facebook, you can add a temp textfield which you can put out of window screen, and when the client click the login button, you perform a delayed selector after 0.1s. In the selector, you first make the temp textfield become the first responder and then do the login logic, so the keyboard stays now. If login failed, you just make your password textfield become first responder. In the above way, it makes sure the keyboard is always seen. Hope it help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜