#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
#if 0
//修改键盘上的return键类型
self.textField.returnKeyType = UIReturnKeyNext;
#endif
#if 0
//点击空白隐藏键盘
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyBoard:)];
[self.view addGestureRecognizer:tapGesture];
#endif
}
//第1种:添加点击手势
/**
* 点击的时候出触发
*
* @param tapGesture <#tapGesture description#>
*/
- (void)hideKeyBoard:(UITapGestureRecognizer *)tapGesture
{
//隐藏键盘
//[self.view endEditing:YES];
//隐藏键盘
[self.textField resignFirstResponder];
NSLog(@"1111111111111");
}
//第2种:实现触摸方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//隐藏键盘
[self.view endEditing:YES];
NSLog(@"222222222222");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
键盘隐藏事件
最新推荐文章于 2021-04-13 10:58:55 发布