Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.WMPageController新增属性 WMScrollView重写一个方法hitTest 用来处理 左右滑动的冲突 #479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions WMPageController/WMMenuView/WMScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@

@interface WMScrollView : UIScrollView <UIGestureRecognizerDelegate>

@property (nonatomic, weak) Class scrollEnableIgnoreClass;

@end
19 changes: 19 additions & 0 deletions WMPageController/WMMenuView/WMScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions WMPageController/WMPageController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions WMPageController/WMPageController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -400,6 +407,7 @@ - (void)wm_setup {
_markedSelectIndex = kWMUndefinedIndex;
_controllerCount = kWMControllerCountUndefined;
_scrollEnable = YES;
_scrollEnableIgnoreClass = nil;
_progressViewCornerRadius = WMUNDEFINED_VALUE;
_progressHeight = WMUNDEFINED_VALUE;

Expand Down Expand Up @@ -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;
}
Expand Down