环境:
view上添加tableView,给view添加单击手势,点击cell却走的是手势方法.
解决:
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
tap.delegate=self;
[self.view addGestureRecognizer:tap];
#pragma mark-手势代理,解决和tableview点击发生的冲突
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//判断如果点击的是tableView的cell,就把手势给关闭了
return NO;//关闭手势
}//否则手势存在
return YES;
}