iOS Question about touches that begin in a UIView's frame and end in its child's.


xStep

macrumors 68020
Jan 28, 2003
2,005
99
Less lost in L.A.
I believe you want to read Event Handling Guide for iOS. As seen in the "The Responder Chain Follows a Specific Delivery Path", the response starts at the child view tapped and works it way through the parents until claimed, or not claimed. If claimed by the child, then normally the event stops there, although as seen in the "Important" entry at the bottom of that document, you can forward it.
 

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,525
22
I believe you want to read Event Handling Guide for iOS. As seen in the "The Responder Chain Follows a Specific Delivery Path", the response starts at the child view tapped and works it way through the parents until claimed, or not claimed. If claimed by the child, then normally the event stops there, although as seen in the "Important" entry at the bottom of that document, you can forward it.
Based on behavior in an app I'm developing, I'm guessing that once a user drags a view into another one, the former view becomes a subview of the latter view, and this latter view responds to the touch events.
 

dejo

Moderator
Staff member
Sep 2, 2004
15,730
447
The Centennial State
Don't guess. Confirm.

Devise a test to validate your presumption. Run the test to see if you are correct or not. Or re-do the test to adjust for something you didn't realize. Rinse and repeat.
 

xStep

macrumors 68020
Jan 28, 2003
2,005
99
Less lost in L.A.
I often do what dejo suggested. I have many little apps where the name begins with the word Sample which makes them easy to find in my dev folder.

Today I created SampleResponderChain and played around with several possibilities and refreshed my memory. I created a subclass of UIView that implements touchesBegan which NSLogs some information. I also used a generic UIView in my testing. I tested what happens when these views are subviews of a common view, and what happens when one is a subview of another. I also tested what occurs when there is overlapping and a view may not be fully contained within another one.

These little apps are a great way to focus on a single interest. They can take from a few minutes to an hour or two of time. I always come away with a better understanding of how Cocoa works.