Separate names with a comma.
Discussion in 'iOS Programming' started by moonman239, Feb 21, 2014.
Which of the two views will receive the message that the touches ended?
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.
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.
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.