iOS 隐藏键盘的几种常见方法
2016-02-27 18:10
417 查看
1.设置return key,然后为Did End On Exit事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]。
2.将背景view设置为UIControl类,然后为Touch Down事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]。
3.重载- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event方法,并在方法内添加代码:[self.textfieldName resignFirstResponder] 或者 [self.view endEditing:YES]。
4.直接执行[[UIApplication sharedApplication]sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; 用于在获得当前UIViewController比较困难的时候。
5.直接执行[[[UIApplication sharedApplication]keyWindow]endEditing:YES]。
2.将背景view设置为UIControl类,然后为Touch Down事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]。
3.重载- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event方法,并在方法内添加代码:[self.textfieldName resignFirstResponder] 或者 [self.view endEditing:YES]。
4.直接执行[[UIApplication sharedApplication]sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; 用于在获得当前UIViewController比较困难的时候。
5.直接执行[[[UIApplication sharedApplication]keyWindow]endEditing:YES]。
相关文章推荐
- iOS截屏方法
- iOS 开发的一些网址
- iOS禁止默认拉伸现象
- iOS中多线程原理与RunLoop一点介绍
- ios开发必备第三方库
- iOS 异步图片加载优化与常用开源库分析
- iOS Block的循环引用问题
- string转换成URL时,如果string中有中文字符,URL无法识别
- iOS,@property,@synthesize, nonatomic,atomic,strong,weak,copy,assign,retain解析
- ioS开发知识(三十二)
- 【iOS开发之静态库、动态库】
- Ios9应用开发基础教程.pdf
- iOS适配的相关内容的整理
- ios 开发中 动态库 与静态库的区别
- ios静态库与动态库的区别
- iOS 定位失败 非洲 经纬度为0,0
- iOS开发调试技巧总结
- 尚学堂IOS开发入门到精通
- 尚学堂IOS开发入门到精通
- iOS block