开发者

How to hide the keyboard in objective-c

I have a simple view wi开发者_JS百科th a textbox and a UIButton. When I click the UIButton I simply want to hide the keyboard that is currently in the view. Is this a simple delegate I can add to the controller or something more complex?

Of the answers that exist on SO already I haven't found one that has a full solution for this context. Any help would be great!


Try something like: [TextField resignFirstResponder]; Where TextField is the name of your text field.


This is how you hide the UITextField when you hit the return button:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

   // do whatever you have to do

   [textField resignFirstResponder];
   return YES;
}

This is how you hide when you hit an UIButton:

- (void)hideTextField:(UITextField *)textField {

   // do whatever you have to do

   [textField resignFirstResponder];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜