Rakius
Rakius

Reputation: 35

Handling thouch events in uiview's subview

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 combinations, 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 :/

Upvotes: 1

Views: 331

Answers (1)

NIKHIL
NIKHIL

Reputation: 2719

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

Upvotes: 1

Related Questions