Reputation: 1527
I am confusing about gesture handing on UIViews,
Say there are three views in the view hierarchy.
Like this image shows:
V1 (Grey)
|
+ V2 (Orange)
|
+ V3 (Red)
Each View has an attached tap gesture,
V1 has gesture1
V2 has gesture2
V3 has gesture3
V3 is too large and is out of bounds of V2.
And below image shows which gesture is responded.
My question is gesture on part of V3 out of bounds of V2:
Why g1 is responded instead of g3? And how to let g3 responses?
Note: I also set v3.userInteractionEnabled = true
, doesn't work
Upvotes: 0
Views: 48
Reputation: 14000
You cannot receive events outside of the bounds of your view. Your orange view will not receive events; hence, it will not be passing events to your red view.
In order to accomplish this, you will need to correct your view hierarchy with either a common parent that groups the orange view and the red view, but is large enough to fit both, or simply attach the gesture recognizer to the grey superview and then compare the location of your touch with the bounds of your views.
Upvotes: 1