标签:
#pragma mark - 添加手势隐藏键盘
- (void)tabBackground
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOnce)];
tap.delegate = self;
[tap setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:tap];
}
- (void)tapOnce
{
[self.textField resignFirstResponder];
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
LXLog(@"%@",NSStringFromClass([touch.view class]));
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
return NO;
}
return YES;
}
标签:
原文地址:http://www.cnblogs.com/TotoroLee/p/5040811.html