ios中隐藏键盘的方式
来源:互联网 发布:js数组元素重新排序 编辑:程序博客网 时间:2024/05/17 04:52
1. 重写view的 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 方法
2. 为view添加tapGesture
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];tapGesture.cancelsTouchesInView = NO;[view addGestureRecognizer:tapGesture];- (void)hideKeyboard{ [self.view endEditing:NO];}
假如view是tableview或者collectionView,如果不设置
tapGesture.cancelsTouchesInView = NO;那么原来的cell将变得不能点击。
[self.view endEditing: NO]的解释
Apple Doc:
"This method looks at the current view and its subview hierarchy for the text field that is currently the first responder. If it finds one, it asks that text field to resign as first responder. If the force parameter is set to YES, the text field is never even asked; it is forced to resign."
3. 可以设置一个透明的大的button响应事件。
0 0
- ios中隐藏键盘的方式
- 在IOS应用中隐藏键盘的几种方式
- IOS中键盘隐藏几种方式
- IOS中键盘隐藏几种方式
- iOS隐藏键盘的几种方式
- iOS中键盘样式设置、隐藏系统键盘的方法
- iOS中UITextField隐藏键盘
- ios 中键盘自动隐藏
- iOS开发中隐藏键盘
- ios 隐藏UITextField的键盘
- iOS 中获得键盘的弹出和隐藏
- iOS中键盘显示与隐藏的套路模版
- iOS开发监听键盘(添加键盘和隐藏键盘,改变视图中整体控件随着键盘的高度移动)
- iOS应用中输入键盘隐藏
- iOS中UITextField return键隐藏键盘
- IOS中键盘隐藏方法总结
- UITextField隐藏键盘的几种方式
- IOS中关闭键盘的两种方式
- 简单易学的机器学习算法——非线性支持向量机
- 数字电路设计之低功耗设计方法二:memory-partition
- Fastjson解析JSON常用方法
- Bug的类型
- VC++ 6.0集成开发环境 编译别人的工程报错 C1083 C2065的可能原因
- ios中隐藏键盘的方式
- OSX 中使用odbc
- Oracle SQL 正则表达式(regular expression)
- 事务时间如何去掉wasted time
- 巧用微信链接消息
- leetcode: LRU Cache
- 1041. Be Unique
- JavaScript的apply和call的使用及区别
- 黑马程序员-基础加强1