From cd38dbde1c0e5a978a147e323d171bee4d9a5f85 Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 6 Feb 2018 16:11:55 +0800 Subject: [PATCH] =?UTF-8?q?1.WMPageController=E6=96=B0=E5=A2=9E=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=20WMScrollView=E9=87=8D=E5=86=99=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=96=B9=E6=B3=95hitTest=20=E7=94=A8=E6=9D=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=20=E5=B7=A6=E5=8F=B3=E6=BB=91=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WMPageController/WMMenuView/WMScrollView.h | 2 ++ WMPageController/WMMenuView/WMScrollView.m | 19 +++++++++++++++++++ WMPageController/WMPageController.h | 4 ++++ WMPageController/WMPageController.m | 9 +++++++++ 4 files changed, 34 insertions(+) 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; }