Reputation: 884
I have two views, one above another as a child. View1--->View2 (View1 has View2 as a child)
How can I code this functionality? 1) if user TAPed on View2 - so the proper message tapped: sent to View2; 2) if user just moving finger over the View1(including View2) - events passed to View1 so it can handle touchesBegan: and so on.
So what I am trying to code is make one function "[View2 tapped:...]" if touch was short, and another function([View1 touchesBegan:..] and so on) if touch is moving.
In my case if I move finger over View2 - it never passes events to View1.
P.s. I did not rewrite hitTest or anything.
Upvotes: 0
Views: 547
Reputation: 437452
Gesture recognizers handle this sort of logic quite elegantly. Have a UITapGestureRecognizer
on view2, and do whatever you want on view1 (e.g. a UIPanGestureRecognizer
). That takes care of all of the "what gestures are recognized by what views" logic you need.
Upvotes: 1
Reputation: 4929
You should look at UIGestureRecognizers
. One of them is UITapGestureRecognizer
- catches taps on targeted UIView
. It's very simple to use. Look Apple documentation.
Upvotes: 1