您的位置:首页 > 其它

如何实现触摸textField以外的地方来关闭键盘?

2012-04-18 18:19 316 查看
第一种:
创建一个不可见的button,将其放在其他所有元素后面,然后在该button的触发事件中写resignFirstResponder.

第二种(更高效的一种方法):

实现touchesBegan方法来隐藏键盘:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

[super touchesBegan:touches withEvent:event];

[textField resignFirstResponder];

//do some other things.

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