views:

1639

answers:

5

Hi there,

I have a series of UIViews inside a UIScrollView, and the UIViewControllers for those views are not receiving the touch events. If I take the views out of the scroll view then it works.

I have enabled userInteraction on the views but it's still not working!

This must be possible and I'd be really grateful if someone could point me in the right direction!

Thanks,

Mike

+1  A: 

Do the views have their own touch handlers, or are you relying on the viewcontroller to get the touches? Depending on how you have set things up, the views may be handling the touches without passing through to the view controller.

mahboudz
The view's don't have their own touch handlers, I've got the handlers in their controllers. This all works when placing the views outside the scrollview but not inside!
Michael Waterfall
A: 

Check what you are returning in scrollview delegate method view for scrollin in scroll view.

As mahboudz mentioned - check if you have any custom handler for touch event. If not, please have one. Its far more relief to do whatever you want to do with your view. Check out Apples sample app from scrollViewSuite. They have tapDetectingImageView delegate. I used the same in my app it worked great! Hope this helps!

AJ
I meant viewForZooming in scroll view and scrollViewDidScroll delegates.
AJ
A: 

I have overcome this issue by overriding the loadView method of the view controller, and setting the view's instance variable to a simple UIView subclass which passes on the touches.

Michael Waterfall
A: 

You may find this post useful. It's an example of a pretty clean way of intercepting events.

DenTheMan
A: 

Have touch handlers for view for which you want to receive touch events and that will work.

Ideveloper