YYTableView.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // YYTableView.m
  3. // YYKitExample
  4. //
  5. // Created by ibireme on 15/9/7.
  6. // Copyright (c) 2015 ibireme. All rights reserved.
  7. //
  8. #import "YYTableView.h"
  9. @implementation YYTableView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. self.delaysContentTouches = NO;
  13. self.canCancelContentTouches = YES;
  14. self.separatorStyle = UITableViewCellSeparatorStyleNone;
  15. // Remove touch delay (since iOS 8)
  16. UIView *wrapView = self.subviews.firstObject;
  17. // UITableViewWrapperView
  18. if (wrapView && [NSStringFromClass(wrapView.class) hasSuffix:@"WrapperView"]) {
  19. for (UIGestureRecognizer *gesture in wrapView.gestureRecognizers) {
  20. // UIScrollViewDelayedTouchesBeganGestureRecognizer
  21. if ([NSStringFromClass(gesture.class) containsString:@"DelayedTouchesBegan"] ) {
  22. gesture.enabled = NO;
  23. break;
  24. }
  25. }
  26. }
  27. return self;
  28. }
  29. - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
  30. if ( [view isKindOfClass:[UIControl class]]) {
  31. return YES;
  32. }
  33. return [super touchesShouldCancelInContentView:view];
  34. }
  35. @end