在开发的时候会遇到一个页面既有点击手势又有tableview,那么这个时候tableview的点击就会被点击手势取代,那么我们应该怎么处理呢?
首先我们先添加一个手势:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissGrantureADD:)];
[tap setNumberOfTapsRequired:1];
tap.delegate=self;
[self.view addGestureRecognizer:tap];
使用手势的代理进行解决
<UIGestureRecognizerDelegate>
#pragmamark - UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
//判断如果点击的是tableView的cell,就把手势给关闭了
returnNO;
//关闭手势
}
//否则手势存在
return YES;
}