問題描述:
view上添加tableView,給view添加單擊手勢,點擊cell卻走的是手勢方法.
解決辦法:
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
tap.delegate=self;
[self.view addGestureRecognizer:tap];
//手勢代理焦蘑,解決和tableview點擊發(fā)生的沖突
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//判斷如果點擊的是tableView的cell,就把手勢給關(guān)閉了
return NO;//關(guān)閉手勢
}//否則手勢存在
return YES;
}