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

点击事件 #22

Open
smartliuliu opened this issue Jun 1, 2017 · 2 comments
Open

点击事件 #22

smartliuliu opened this issue Jun 1, 2017 · 2 comments

Comments

@smartliuliu
Copy link

屏幕中间的view可以点击,两侧的View不能点击,我看了代码好像是超出父类的范围

@PageGuo
Copy link
Owner

PageGuo commented Jun 1, 2017

更改项目里- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;

  • (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    if ([self pointInside:point withEvent:event]) {
    CGPoint newPoint = CGPointZero;
    newPoint.x = point.x - _scrollView.frame.origin.x + _scrollView.contentOffset.x;
    newPoint.y = point.y - _scrollView.frame.origin.y + _scrollView.contentOffset.y;

       if ([_scrollView pointInside:newPoint withEvent:event]) {
       return [_scrollView hitTest:newPoint withEvent:event];
      }
    
      for (PGIndexBannerSubiew *view in _scrollView.subviews) {
            if (CGRectContainsPoint(view.frame, newPoint)) {
           return view;
       }
    

    }
    return _scrollView;
    }

    return nil;
    }

@wncios
Copy link

wncios commented Dec 28, 2018

按照这种方法设置过后点击侧边的View,滑动到对应的View且居中会出现Bug。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants