I have a transparent UIView with a UIPanGestureRecognizer that sits on top of everything else in my view controller, along the right side of the screen. This is allowing me to drag left from anywhere along the right side of the screen to reveal a side menu, as I'm sure everyone can picture. The problem is that this UIView blocks any tap gestures, such that if there's a button somewhere underneath the UIView that contains UIPanGestureRecognizer, the button doesn't respond. There are lots of similar questions out there, but I can't find any solution that actually fixes this problem. I only want this UIPanGestureRecognizer to do anything when the user actually drags; otherwise, I want the touch to be passed through the transparent UIView to whatever is underneath. Can anyone help me out?
Asked
Active
Viewed 743 times
0
cowfaboo
- 709
- 1
- 8
- 15
-
Did you tried `cancelTouchesInView = NO` for your pan gesture ? – danypata Nov 27 '13 at 21:00
-
It should really work. In interface builder, set the pan gesture recognizer's "Canceled in View" and "Delayed End" to enabled (ticked). Also make sure the button is enabled, and User Interaction Enabled set to yes. If you encapsuled the button into a view or something, make sure that this parent view has also these flags enabled. – nzs Nov 27 '13 at 22:01
-
And one more thing: if the parent uiview has no frame, then no click event will be detected (it can happen if you create programatically without setting the frame property - it will render in UI but touch event won't be delivered) – nzs Nov 27 '13 at 22:06
-
Haven't touch IOS for a while but please try this. Make your viewController into a UIScrollViewController... Remove the UIView with pan... Detect drag motion on Main View. Almost 100% sure something like this will work. – TtheT Nov 27 '13 at 22:36
-
Another approach is detect the touch position, compare to available clickable items position and shoot them... This one aint good but sure as hell will work :p – TtheT Nov 27 '13 at 22:41
-
Can you please update your question with a high level view hierarchy? It might help to understand more the problem. – nzs Nov 28 '13 at 09:43