ios-点击屏幕,隐藏键盘

ios-点击屏幕,隐藏键盘

- (void)getFirstRegist{
//结束键盘编辑
__weak typeof(self)weakSelf = self; UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenKeyBoard)];//注意是UITapGestureRecognizer
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];//主队列 //在键盘出现之前,这个函数会被触发(键盘内置的方法,来获取这个通知中的消息)
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification object:nil queue:mainQueue usingBlock:^(NSNotification *note) {
[weakSelf.view addGestureRecognizer:tapGestureRecognizer];
}];
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:mainQueue usingBlock:^(NSNotification *note) {
[weakSelf.view removeGestureRecognizer:tapGestureRecognizer];
}];
} - (void)hiddenKeyBoard{
[self.view endEditing:YES];
}
上一篇:如何安装 第三方 Go 离线包? (GOPATH、 go install)


下一篇:ubuntu制作离线包