今天写 项目tableViewcell点击没反应 cell上有点击手势
先获取点击手势 加判断
self.view.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped:)];
singleTap.delegate = self;
singleTap.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:singleTap];
#pragma mark ------UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// 输出点击的view的类名
NSLog(@"%@", NSStringFromClass([touch.view class]));
// 若为UITableViewCellContentView(就是击了tableViewCell),则不截获Touch事件(就是继续执行Cell的点击方法)
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
return NO;
}
return YES;
}
根据view的类名 判断点击哪一个