收录日期:2019/12/07 11:53:34 时间:2010-10-28 14:08:49 标签:iphone,objective-c,iphone-sdk-3.0,ios4

I have a 4 UIViews inside a UIScrollView. Assume 1 of it is a chart like in iphone stocks aplication. When I move the finger across the chart I need to draw a vertical line.I can use the touchesMoved for that.

But Also I need to move horizontally scroll my views. Problem is when I move my finger across the chart, UIScrollView scrolls horizontally.

How can i avoid this and identify those 2 as different events?

UIScrollView forwards touches to subviews only after a small delay. If a touch is moved until this delay fires, UIScrollView interprets the touch as move of contentOffset. To touch your subview try to hold it for a second, then start moving.

You can set delaysContentTouches on scrollView to NO, then touches are forwarded immediately.

I found the solution here.

On the touchesBegan method I need to make the UIScrollView's scrolling disabled. Then inside the touchesEnded I need to make the scrolling enabled again.