Michael Waterfall
Michael Waterfall

Reputation: 20569

Touch events not working on UIViews inside UIScrollView

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

Upvotes: 3

Views: 5013

Answers (5)

Ideveloper
Ideveloper

Reputation: 1463

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

Upvotes: 0

DenTheMan
DenTheMan

Reputation: 1277

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

Upvotes: 0

Michael Waterfall
Michael Waterfall

Reputation: 20569

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.

Upvotes: 1

AJ.
AJ.

Reputation: 1463

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!

Upvotes: 0

mahboudz
mahboudz

Reputation: 39376

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.

Upvotes: 1

Related Questions