0
votes

I have a UIView ViewA, that we are adding to a scrollView ViewB. ViewA has other subviews (one of them is, ViewC). Now, we have touches methods (did begin, did end etc) on ViewA. ViewC has a tap recognizer. How do I pass the touch ?

Right now, the touches methods in ViewA are being hit. The gesture recognizer is not working.

Can anyone kindly suggest anything ?

Thanks. Ahsan

2

2 Answers

1
votes

I would recomand you to use a UIGestureRecognizer adapted to what you want to do instead of implementing directly the touch methods. According to Apple documentation, your are not supposed to use touch methods anymore.

If you want to pass a gesture from one view to another one, why don't you declare a method in the .h file of your second view and call it from the first view when the gesture is triggered ?

It's even simpler if viewB is a subview of viewA as you will have a reference of vewB in viewA.

Hope this help!

1
votes

You can make one UIGestureRecognizer (A) dependant on another one (B) - so that one can't work without the second one failing.

In your case, you might add a UIGestureRecognizer (A) to the top view, and another one (B) to the view under it, that needs to recognise some other user interaction. The one (B) on the bottom view can't start working without the the other one (A) failing.

For more UIGestureRecognizer behaviour that might suit your needs, you can read about requireGestureRecognizerToFail here and just familiarise yourself with the class that's super-useful.