iOS 三种收起键盘的方法
2015-08-11 21:26
369 查看
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(10, 100, 200, 200)]; textField.backgroundColor=[UIColor redColor]; [self.view addSubview:textField]; } //第一种收起键盘的方法 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self.view endEditing:YES]; } //第二种收起键盘的方法 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; } //第三种收起键盘的方法 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [[[UIApplication sharedApplication] keyWindow] endEditing:YES]; }
相关文章推荐
- IOS 本地通知和远程通知
- iOS项目开发实战——网页源代码实现二进制和HTML的转换
- iOS开发之OC实例可见度,方法
- iOS开发-Day18-OC NSArray&NSMutableArray
- 前言:关于nagios监控
- 前言:关于nagios监控
- OC_AddressBook_通讯录写入
- iOS项目开发实战——获取网页源代码的二进制数据
- iOS-开发技巧-三种收起键盘的方法
- iOS开发-Day17-OC NSString / NSMutableString常用方法
- iOS开发之OC类和对象
- MKNetworkit,Express实现简单登录验证(1)
- iOS之NSBundle简介
- iOS __weak与__block修饰符到底有什么区别
- iOS 多线程使用
- iOS开发-Day15-OC继承与多态
- iOS中block和代理的使用
- 关于iOS的强引用,弱引用及strong,retain,copy,weak,assignd的关系
- iOS7 NavigationController 右滑手势失效问题
- iOS开发-Day13-OC基础、面向对象