I've got several cells containing views in this structure:
The cells partly overlap. This means that the main view of cell A will partly cover the frontview of cell B. Like this:
I want to intercept touches on frontviews and backviews, but I want main views to ignore them.
(I've tried disabling user interaction on main views, but that also disables front and back views).
Any tips?
I found an answer here: http://vectorvector.tumblr.com/post/2130331861/ignore-touches-to-uiview-subclass-but-not-to-its
Basically, I'm making the main view a subclass of UIView, and overriding hitTest with this:
-(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
id hitView = [super hitTest:point withEvent:event];
if (hitView == self) return nil;
else return hitView;
}
(Note that confusingly you must set UserInteractionEnabled to true, ticked, yes for the UIView in question!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With