Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView inside UIScrollView not getting touch events

My view hierarchy looks like this:

-UIScrollView
---UIView
------CustomUIView
------CustomUIView

I have implemented touchesBegan in CustomUIView, but it's not getting called.

Can someone please tell me how I can get my CustomUIView to detect touches?

like image 217
user635064 Avatar asked Dec 01 '25 14:12

user635064


2 Answers

Try the following and check:

[scrollView setCanCancelContentTouches:NO];
like image 117
HG's Avatar answered Dec 03 '25 03:12

HG's


You may have solved this now but I had a similar problem and solved it so hopefully my experience can help anyone else with a similar issue.

In my case I had exactly the same setup my CustomUIView was capturing the touch events. In order to have UIView receive any touch events I needed to make a call to

[super touchesEnded:touches withEvent:event];

from the CustomUIView. Hope this helps!

like image 34
Thomas Avatar answered Dec 03 '25 05:12

Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!