I have a simple app which adds a subview over the main view when the user clicks on a UIButton in the main view. This subview is of size 480×320 (I’m in landscape mode), but there is a boarder around the centre image in this subview which is transparent.
This is where my problem lies. I would like only the subview to process touches until it is removed from the superview, but if there is a touch event on the transparent boarder, the event gets passed to the superview, and ignores the subview, even though the subview is the full size of the window.
Doing some research into this, it seems as though this is what apple intended to happen, as touches will only get passed to opaque sections, even if the subview is the full size of the window. It is explained in the reference:
I would like to be able to set it such that the touches will stay with the subview, regardless of any transparency issues. The hitTest:withEvent: method seems to do something like this, but more for passing touches to different subviews then the one that was touched.
Is there anyone who has a fix/work-around that can achieve this?
You should just put a clear button in the back of the xib. That will prevent touch events from going off.