Skip to content

在 scrollView 下会有冲突 要是改下这个就无敌了 #3

Description

@wusu2016
  • (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    NSLog(@"shouldRecognizeSimultaneouslyWithGestureRecognizer---%@", otherGestureRecognizer);
    if ([otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPanGestureRecognizer")] || [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIPanGestureRecognizer")]|| [otherGestureRecognizer isKindOfClass:NSClassFromString(@"UIScrollViewPagingSwipeGestureRecognizer")]){
    //冲突要有两个,二者不可兼得
    UIView *aView = otherGestureRecognizer.view;
    if ([aView isKindOfClass:[UIScrollView class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
    UIScrollView *sv = (UIScrollView *)aView;

         CGFloat svWidth = sv.contentSize.width;
         NSInteger subViewsNum = svWidth/[UIScreen mainScreen].bounds.size.width;
          
          //设置左滑和右滑的情况
          // 右滑的情况
          
          // 如果是scrollView多视图  类似附近 广场 推荐的滚动
          if([sv isKindOfClass:[UITableView class]]){
              return NO;
          }
          // 如果是scrollView多视图  类似附近 广场 推荐的滚动 if ((sv.contentOffset.x < 0) && (subViewsNum > 1)){
         if ((sv.contentOffset.x <= 0) && (subViewsNum > 1)){
              return YES;
          }
          
          
      }
    

    }
    return NO;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions