iOS开发解决TableView与view手势冲突
2017-09-11 本文已影响445人
西瓜皮奥特曼
手势代理UIGestureRecognizerDelegate
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHiden)];
tap.delegate=self;
[self.view addGestureRecognizer:tap];
#pragma mark- UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
return NO; //关闭手势
}
return YES;
}
参考链接http://blog.csdn.net/liumude123/article/details/51416555