[Original] passing the sliding event of UIScrollView to its subview

Source: Internet
Author: User

When developing a project, I encountered a problem:

In my UIScrollViewOut, A UIScrollViewIn is embedded,

When I want to drag UIScrollViewIn, UIScrollViewOut changes, while UIScrollViewIn does not. However, you only need to press and hold UIScrollViewIn and drag it again. UIScrollViewIn will be able to slide.

 

How UIScrollView works:

UIScrollView reloads the hitTest method. When you touch your finger, UIScrollView intercepts all events and waits for 150 ms. During this period, if no finger is moved, when the time ends, UIScrollView sends the tracking event to the subview without moving itself. When the finger moves before the end of the time, UIScrollView slides to cancel tracking.

 

It seems that this is a problem with UIScrollViewOut. Drag UIScrollViewIn directly. If the touch time is less than ms, UIScrollViewOut considers it to be dragging itself, thus blocking the event. As a result, UIScrollViewIn cannot accept the sliding event. However, you only need to hold down UIScrollViewIn and drag it again. At this time, the touch time exceeds 150 ms, so the sliding event will be sent to UIScrollViewIn.

 

I tried several methods during this period. Only one method is feasible. It is to rewrite the hitTest method of UIScrollViewOut: When sliding UIScrollViewIn, UIScrollViewOut cannot be slide.

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)* result = [super hitTest:point withEvent: ([result.superview isKindOfClass:[UIScrollViewIn ==

PS:

I have tried several methods, for example, changing UIScrollViewIn to firstResponder, rewriting the hitTest method in UIScrollViewOut, and always returning the UIScrollViewIn pointer.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.