- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
self.delaysContentTouches = NO;//
self.canCancelContentTouches = YES;
self.separatorStyle = UITableViewCellSeparatorStyleNone;
// Remove touch delay (since iOS 8)
UIView *wrapView = self.subviews.firstObject;
// UITableViewWrapperView
if (wrapView && [NSStringFromClass(wrapView.class) hasSuffix:@"WrapperView"]) {
for (UIGestureRecognizer *gesture in wrapView.gestureRecognizers) {
// UIScrollViewDelayedTouchesBeganGestureRecognizer
if ([NSStringFromClass(gesture.class) containsString:@"DelayedTouchesBegan"] ) {
gesture.enabled = NO;
break;
}
}
}
return self;
}
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ( [view isKindOfClass:[UIControl class]]) {
return YES;
}
return [super touchesShouldCancelInContentView:view];
}
1、设置delaysContentTouches属性为NO,取消UIScrollView在接收到手势的时候的延迟
2、取消延迟手势
3、实现touchesShouldCancelInContentView方法