My problem: I have an EditView supervisor that takes up basically the entire frame of the application, and a subview MenuView that takes up only the bottom ~ 20%, and then the MenuView contains its own subview ButtonView , which is actually outside the boundaries of the MenuView (something like this: ButtonView.frame.origin.y = -100 ).
(Note: EditView has other subqueries that are not part of the hierarchy of the MenuView , but may affect the response.)
You probably already know the problem: when a ButtonView is within a MenuView (or, more specifically, when my touches are within a MenuView ), a ButtonView responds to touch events. When my touches are outside the boundaries of the MenuView (but still within the bounds of the ButtonView ), the ButtonView event ButtonView not receive a touch event.
Example:
- (E)
EditView , the parent of all views - (M)
MenuView , subtitle EditView - (B) -
ButtonView , a subview of the MenuView menu
Diagram:
+------------------------------+ |E | | | | | | | | | |+-----+ | ||B | | |+-----+ | |+----------------------------+| ||M || || || |+----------------------------+| +------------------------------+
Since (B) is outside (M), a short press in area (B) will never be sent to (M) - in fact, (M) never analyzes the touch in this case, and the touch is sent to the next object in the hierarchy.
Purpose: I understand that overriding hitTest:withEvent: can solve this problem, but I don't exactly understand it. In my case, if hitTest:withEvent: will be overridden in EditView (my "supervisor")? Or should it be redefined in MenuView , a direct view of a button that does not receive touches? Or am I thinking about it wrong?
If this requires a long explanation, a useful online resource will be useful - with the exception of Apple UIView docs that didn't let me know.
Thank!
ios objective-c
toblerpwn Aug 02 2018-12-12T00: 00Z
source share