行业新闻您现在的位置:主页 > 新闻资讯 > 行业新闻 >

iOS点击键盘以外空白区域隐藏键盘的常见方法

发布日期:2016-12-15 23:06

01
- (void)viewDidLoad
02
{
03
[super viewDidLoad];
04
// Do any additional setup after loading the view, typically from a nib.
05
UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget:self 
action:@selector(viewTapped:)];
06
tapGr.cancelsTouchesInView = NO;
07
[self.view addGestureRecognizer:tapGr];
08
}
09
-(void)viewTapped:(UITapGestureRecognizer*)tapGr
10
{
11
[textfield resignFirstResponder];
12
}
客服软件
live chat