UITextField点击textField外任意区域键盘回收(一)---- [UIAppllication shareApplication]
来源:互联网 发布:博爱网络智能路由中继 编辑:程序博客网 时间:2024/05/21 08:02
最近做的项目用到好多textField, 涉及到键盘回收,键盘挡住textField 上移textField等,自己水平不够,深感textfield好复杂,想好好整理下自己会得用法,继续学习不会的用法。。
键盘回收有好多中方法:UITextFieldDelegate, 在self.view上添加UIControl, TouchesBegan方法,[UIAppllication shareApplication]方法
其中点击textField外任意区域回收键盘,这三种方法可以实现:self.view上添加UIControl, TouchesBegan方法,[UIAppllication shareApplication]
方法1 [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
1、第一步
- (void)viewDidLoad {
[super viewDidLoad];// Do any additional setup after loading the view.
self.automaticallyAdjustsScrollViewInsets = NO;
//创建self.view上的各种控件。。。。
//创建完所有控件后,在此添加手势 保证加在self.view的最外层
//设置点击任何其他位置 键盘回收
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBG:)];[self.view addGestureRecognizer:tapGesture];
}
2、第二步 手势action 调用UIApplication sharedApplication
- (void)tapBG:(UITapGestureRecognizer *)gesture {
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
}
即可实现点击textField外任意区域回收键盘。。。
- UITextField点击textField外任意区域键盘回收(一)---- [UIAppllication shareApplication]
- UITextField点击textField外任意区域键盘回收(二)---- TouchesBegan
- textField键盘回收
- iOS textField 回收键盘
- UITextField,UITextView回收键盘
- 1.UITextField 只能输入数字和点 2.textField回收键盘
- android点击任意非EditText区域,隐藏键盘
- UITextField的键盘回收用法
- UITextfield resignFirstResponder键盘不回收
- UITextField / UIButton / 回收键盘delegate
- UITextField的键盘的回收
- UITextField *textfield常用的取消键盘方法
- 点击TextField禁止弹出键盘
- 点击空白回收键盘
- UITextField 点击非文本框区域使键盘消失的三种方法
- 点击UITextField不弹出键盘
- UITextField点击空白键盘退去
- Textfield的属性设定和键盘回收
- android发现之旅之ViewRootImpl,Activity,Window,DecorView之间的关系
- VB.NET 用循环判断文本框是否为空
- linux shell实现随机数多种方法(date,random,uuid)
- 第13周、项目—验证算法 (2)
- poj 1201 Intervals
- UITextField点击textField外任意区域键盘回收(一)---- [UIAppllication shareApplication]
- IO多路复用之epoll
- 1076. Forwards on Weibo
- Java中的命令模式——Thread,ThreadPoolExecutor和Runnable
- JAVA正则表达式匹配,替换,查找,切割
- ThinkPHP 3.2中vendor()方法的深入研究及PHPMailer的正确扩展
- ionic省市县三级联动
- win10 IE内核浏览器不能上网的问题
- linux下 查看外网IP命令