diff --git a/WMPageController/WMMenuView/WMScrollView.h b/WMPageController/WMMenuView/WMScrollView.h index b4b25b3..dd2b150 100644 --- a/WMPageController/WMMenuView/WMScrollView.h +++ b/WMPageController/WMMenuView/WMScrollView.h @@ -10,4 +10,6 @@ @interface WMScrollView : UIScrollView +@property (nonatomic, weak) Class scrollEnableIgnoreClass; + @end diff --git a/WMPageController/WMMenuView/WMScrollView.m b/WMPageController/WMMenuView/WMScrollView.m index 8de0ac6..2fdd6fc 100644 --- a/WMPageController/WMMenuView/WMScrollView.m +++ b/WMPageController/WMMenuView/WMScrollView.m @@ -20,4 +20,23 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequire return NO; } +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event +{ + UIView *result = [super hitTest:point withEvent:event]; + + if(self.scrollEnableIgnoreClass != nil) + { + if([result isKindOfClass:[self.scrollEnableIgnoreClass class]]) + { + self.scrollEnabled = NO; + } + else + { + self.scrollEnabled = YES; + } + } + + return result ; +} + @end diff --git a/WMPageController/WMPageController.h b/WMPageController/WMPageController.h index 0836c95..4536064 100755 --- a/WMPageController/WMPageController.h +++ b/WMPageController/WMPageController.h @@ -176,6 +176,10 @@ extern NSString *const WMControllerDidFullyDisplayedNotification; /** Whether the controller can scroll. Default is YES. */ @property (nonatomic, assign) BOOL scrollEnable; +//scrollEnable 为YES下 左右滑动会和一些类冲突 +//可以设置scrollEnableIgnoreClass暂时禁用scrollEnable +@property (nonatomic, copy) Class scrollEnableIgnoreClass; + /** * 选中时的标题尺寸 * The title size when selected (animatable) diff --git a/WMPageController/WMPageController.m b/WMPageController/WMPageController.m index f65f77b..9cad394 100755 --- a/WMPageController/WMPageController.m +++ b/WMPageController/WMPageController.m @@ -104,6 +104,13 @@ - (void)setScrollEnable:(BOOL)scrollEnable { self.scrollView.scrollEnabled = scrollEnable; } +- (void)setScrollEnableIgnoreClass:(Class)scrollEnableIgnoreClass { + _scrollEnableIgnoreClass = scrollEnableIgnoreClass; + + if (!self.scrollView) return; + self.scrollView.scrollEnableIgnoreClass = scrollEnableIgnoreClass; +} + - (void)setProgressViewCornerRadius:(CGFloat)progressViewCornerRadius { _progressViewCornerRadius = progressViewCornerRadius; if (self.menuView) { @@ -400,6 +407,7 @@ - (void)wm_setup { _markedSelectIndex = kWMUndefinedIndex; _controllerCount = kWMControllerCountUndefined; _scrollEnable = YES; + _scrollEnableIgnoreClass = nil; _progressViewCornerRadius = WMUNDEFINED_VALUE; _progressHeight = WMUNDEFINED_VALUE; @@ -436,6 +444,7 @@ - (void)wm_addScrollView { scrollView.showsHorizontalScrollIndicator = NO; scrollView.bounces = self.bounces; scrollView.scrollEnabled = self.scrollEnable; + scrollView.scrollEnableIgnoreClass = self.scrollEnableIgnoreClass; if (@available(iOS 11.0, *)) { scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; }