Do CALayers block touch events on base views?

I have an application with a view that contains multiple subzones. Subsections did not implement any touchhesbegins logic. Superview implemented all the logic of the touchhesbegins and manipulated each subzone accordingly if it was affected (determined by hit testing).

I have since converted my subzones to layers. My problem is that if I touch the layer the super layer hosting view will never get the touchhesbegins method called. However, if I touch the background, the touchhesbegin method fires.

I understood from the documentation that layers cannot handle events, if so why is it blocking events in the hosting view?

Thanks for any help, can't get around this.

-Corey

0


source to share


3 answers


CALayers should not block touch events. Is your flag userInteractionEnabled

set in the hosting view (seems like it is if you get SOME finishing touches)? It's inside a UIScrollView that can do its own touch handling.



+1


source


I found the problem ... I was releasing sublayers that I created using [CALayer layer]. Since I had no control over them, I did not have to control them.



+2


source


Which class does your touchBegan method use? I had a similar problem because my touchhesBegan method was in a UIView subclass. After moving the method to a UIViewController subclass, my problem was fixed.

Try this.

0


source







All Articles