开发者

objective C touch events problem

开发者 https://www.devze.com 2023-01-22 04:47 出处:网络
I have a 4 UIViews inside a UIScrollView. Assume 1 of it is a chart like in iphone stocks aplication. When I move the finge开发者_JS百科r across the chart I need to draw a vertical line.I can use the

I have a 4 UIViews inside a UIScrollView. Assume 1 of it is a chart like in iphone stocks aplication. When I move the finge开发者_JS百科r 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.

0

精彩评论

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