In the daily development, we often use uiscrollview, however, it is a problem-frequency control, For example, if you use it in nib, you must create a contentview for it manually. Of course, the use of the spring code when using lazy loading mechanism so that it can have a contentview, today we do not talk about this problem, Let's talk about Uiscrollview's event interception related knowledge.
Before you get to the point, fill in the knowledge points: The response chain "responder Chain".ios device has a lot of elements on the screen when the user triggers an event:
User-triggered events--system framework Uikit Create an event object that contains various information about the event, add it to the event queue in the foreground app, and uiapplication the event to the current Window object ( Generate different new objects based on different event objects)
① Touch event, pass new object---Trigger Event view (hit-testing).
② shake or Remote control event the->window object passes a shake event or remote control event to the first responder to handle.
Now let's talk about a phenomenon:
1> Add a Contentview on the Uiscrollview, add a few buttons on the Contentview, run
You will find that there is a delay when the button is clicked,
2> set Delaycontentstouches to No
You will find that you cannot slide scrollview on the button
3> customizes a class, inherits Uiscrollview, Overrides Method-(BOOL) Touchesshouldcancelincontentview: (UIView *) view, and returns Yes directly:
You will find that the problem is solved.
Uiscrollview Event Interception