您的位置:首页 > 移动开发 > IOS开发

ios 关闭键盘的常见方法

2014-04-25 18:05 232 查看
   首先.h中声明关闭虚拟键盘方法-(IBAction)closeKeyBoard:(id)sender;

   .m中实现:

方法一:拖一个Button到view中,并将它铺满整屏,设置按钮样式为Custom,即无外观。连接button的touch up inside方法即可。

-(void)closeKeyBoard:(id)sender

{

   [textFieldName resignFirstResponder];

}

方法二:在主view的identity inspector中将custom class改为UIcontrol,这样就能够触发操作方法。实现方法同一,然后连接view的touch up inside方法即可。

方法三:当textfield很多时,使用此方法可以不用一个个遍历输入框。

-(void)closeKeyBoard:(id)sender

{

    [self.view endEditing:YES];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 关闭虚拟键盘