初始化手势
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapCell:)];
tap.delegate = self;
[self.view addSubview:tap];
在UIGestureRecognizerDelegate中
#pragma mark UIGestureRecognizerDelegate
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if([NSStringFromClass([touch.view class]) isEqualToString:@" UITableViewCellContentView "]){
return NO;
};
return YES;
}
但是我在开发中遇到的一个奇怪的问题就是他在ios8 上会与系统自带的左划返回冲突会导致程序crash,crash 在 :
gestureRecognizer:gestureRecognizer shouldReceiveTouch:
我的解决办法是将
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
我也不清楚是为啥,不仅程序不crash了,而且系统自带的返回手势还能继续用