//<UIGestureRcognizerDelegate> 需要实现
//添加手势
- (void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(touch)];
tapGes.delegate =self;
[self.view addGestureRecognizer:tapGes];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
returnNO;
}
returnYES;
}
#pragma mark -添加手势
- (void)touch {
[self.view endEditing:YES];
}
网友评论