开发者

Handling thouch events in uiview's subview

开发者 https://www.devze.com 2023-04-03 13:38 出处:网络
I\'m facing a weird problem with uiviews events, i have search over stackoverflow and similar, wasting a bunch of hours, but none of found replies helped me... i´m still stuck.

I'm facing a weird problem with uiviews events, i have search over stackoverflow and similar, wasting a bunch of hours, but none of found replies helped me... i´m still stuck.

I have one scrollview, with several custom subviews (called 'CustomA') inside. Those CustomA subviews have some sublayers and one custom subview (called 'CustomB'). The scrollview is inside uiviewcontroller is setted up in IB, the rest of interface elements are setted up in code.

|-------------------------................................... <----- ScrollView

||-----------------|

||                     |

||                     |<--- CustomA

||   some         |

||   sublayers   | ..........................

||                     |

||                     |

||-----------------|

||   CustomB    |

||-----------------|

|-------------------------...................................

The scrollview works fine, i can scroll left and right, and if i touch CustomA, it fires touchesBegan:withEvent: as expected, but when i touch CustomB (CustomA subview), touch events are not fired. The method touchesBegan:withEvent: is implemented in both custom subviews, and i have tried setting userInteractionEnabled, coding hitTest:withEvent:, pointInside:withEvent: and much more combi开发者_StackOverflow社区nations, but still fails. I´m pretty sure it's my fault but can't see the problem.

Could anyone help me, please? i'm desperate.

Thank you in advance and sorry for my seedy english :/


in the following link there will be three demo

check the autoscroll example

as per your desire check tapdetecting TapDetectingImageView.h and .m file where your customB subview's tap event will get detected

http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008904

regards

0

精彩评论

暂无评论...
验证码 换一张
取 消