Touches on/in UIScrollView

17 views
Skip to first unread message

Antonio Curci

unread,
Nov 1, 2009, 3:24:54 PM11/1/09
to iPhone SDK Development
Hi,
I'm from Italy and I'm sorry for my english.
I have this structure:
UIView-->UIScrollView-->a sort of UIView
So, the first UIView is in a xib controlled by a UIViewController and
the UIScrollView too (in the same xib and controlled by the same
UIViewController with a <UIScrollViewDelegate> ). The "sort of UIView"
is CPLayerHostingView with the outlets "view" connected to an other
UIViewController. CPLayerHostingView is declared in the core-plot
framework.
Therefore on this "sort of UIView" i can't handle touch gesture with
"- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event" .
So, my question is: how i can force the first UIViewController to
handle the touch gesture?

Robbonz

unread,
Nov 3, 2009, 5:04:25 PM11/3/09
to iPhone SDK Development
Hi,
I have recently been working in a similar area to this and it wasn't
easy and took some time to get right. In some cases my "content
view" (the view within the UIScrollView) needs to respond to gestures,
in other cases it doesn't. Here are some of the things I had to do to
get this working:

1. I subtyped UIScrollView and overrode
touchesShouldCancelInContentView: to return YES or NO depending on
when I needed the subview to receive touch events (depends on zoom
level, number of fingers touching the screen).
2. myUIScrollView.canCancelContentTouches = YES. When it's YES, the
scroll view calls the above method. If it's NO, the scroll view never
calls the above method.
3. myContentView - handles touchesBegan:, touchesMoved:, etc.

I hope this can help you out.
Reply all
Reply to author
Forward
0 new messages