ios-点击屏幕,隐藏键盘
- (void)getFirstRegist{
__weak typeof(self)weakSelf = self;
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenKeyBoard)];
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];
}