//<UIGestureRcognizerDelegate> 需要實現(xiàn)
//添加手勢
- (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];
}