views:

103

answers:

1

I'm trying to pass touch events from a UIImageView to a UIScrollView and it doesn't appear to be working. I've tried to define my screen elements below. Essentially, the overlaidImage will be the first to respond to all events. If a condition is met, I want it to handle the events. If not, I want it to be passed to the imageView and then along to the scrollView. My code works just fine to pass the events to the imageView and even to pass the events to the scrollview, but the scrollview doesn't respond to pinch/zoom events. As soon as I remove the overlaid image from the mainView, everything works as expected.

My application is setup as follows:

mainView

mainView->scrollView

mainView->scrollView->imageView

mainView->overlaidImage

A: 

If the overlaidImage is not a child of the scrollView how could you possibly expect the scrollView to react to touches in the overlaidImage? Could you make the example more concrete to make it easier to understand?

willcodejavaforfood
Sorry my explanation was not clear enough. The overlaidImage implements the touchesBegan/touchesMoved method. If a certain condition is met, it responds to the touch and all is fine. If the condition isn't met it is passed up the responder chain to the mainView. mainView has also implemented touchesBegan/touchesMoved which I forward to the scrollview. However, pinching/zooming doesn't work. If I create a custom scrollview and override touchesBegan/touchesMoved I can see that the methods are being called, but pinch/zoom doesn't work.
Mike
I was able to resolve the issues by overriding the hittest method in the overlaidimage and having it control which view was supposed to receive the touch events rather than forcing in touchesBegan/etc.
Mike
glad you managed to fix it :)
willcodejavaforfood