开发者

Touching in UIScrollview?

I am using ScrollviewDelegate Protocol in viewcontroller, but I am using Custom UIView(UIImageview) in that custom view.

For some reason, touchMoved开发者_如何学Go is not being called. Does anyone have any ideas why this is (not) happening?


If scrolling in UIScrollView is enabled then touchMoved events are not propagated to the scroll view contents. How to workaround that depends on what you want to achieve. In my application I needed just to drag an object inside UIScrollView and I did the following in contentsView touch handlers for that:

  1. In touchesBegan: event I checked if I tapped object to be dragged. If YES - then disabled scrolling in UIScrollView
  2. Then as scrolling was disabled my contents view started to receive touchesMoved event and I could "drag" my object there.
  3. In touchesEnded: I reenabled scrolling.

If you want something more complex you can subclass UIScrollView and try to override its touch handlers (see also hitTest:withEvent: method)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜