Reputation: 12954
For an iPad app I am writing I have a container UIView with two subview that are UIView subclasses:
Since the UIImageView overlaps the UIButton spatially it is preventing touches from reaching the UIButton even though the UIButon is fully visible due to the alpha matte cutout in the UIImageView. How do I allow the UIImageView to pass touches to it's sibling UIButton?
Thanks,
Doug
Upvotes: 4
Views: 2940
Reputation: 5066
Even with user interaction enabled, which is the default value when placing a UIImageView in Interface Builder, the touches should pass through to your button underneath, even if your image view has a solid background. Something else must be going on like a UIView sitting on top of the button.
If you are trying to do something more complex to get touches to pass through to underlying views or a separate view controller whose view is underneath, I created this simple open source library:
https://github.com/natrosoft/NATouchThroughView
The REAMDE and demo show how to use it.
Upvotes: 0
Reputation: 1725
In addition to Bastian's answer it was also necessary for me to uncheck the Opaque
drawing attribute in interface builder for my UIImageView
Upvotes: 0
Reputation: 10433
UIImageView usually won't block touches, UIViews do.
You can set the userInteractionEnabled property on the overlapping views to NO, then touches should go through them.
An other approach would be writing a custom hitTest that redirects the thouches to the button.
Upvotes: 4