UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
singleTap.delegate = self;
[self.view addGestureRecognizer:singleTap];
[singleTap release];
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view isKindOfClass:[UIButton class]]) {
return NO;
}
if ([touch.view isKindOfClass:[UITableViewCell class]]) {
return NO;
}
if ([touch.view isKindOfClass:[UIScrollView class]]) {
return YES;
}
return NO;
}
需要加UIGestureRecognizerDelegate这个协议