简体   繁体   English

UIScrollview 触动

[英]UIScrollview touches

I have an instance of UIScrollView which I'm allowing the user to zoom in/out.我有一个UIScrollView的实例,我允许用户放大/缩小。 I've implemented a delegate to take care of this as per the docs.我已经按照文档实现了一个委托来处理这个问题。 However, I'd like to know where the user is touching the scrollview (relative to the scrollview's superview's frame).但是,我想知道用户触摸滚动视图的位置(相对于滚动视图的超级视图框架)。 Can I intercept this information, such as via some property of scrollviews, without overriding say touchesMoved:withEvent: ?我可以拦截这些信息,例如通过滚动视图的某些属性,而不覆盖说touchesMoved:withEvent:吗?

[ UIScrollView instances internally make a decision on the type of touch they received. [ UIScrollView实例在内部决定它们收到的触摸类型。 I don't want to emulate this, I'd like to know the decision and the location of the touch.]我不想效仿这个,我想知道触摸的决定和位置。]

There is no property in scroll view which will tell you the location of the touch.滚动视图中没有属性可以告诉您触摸的位置。 You can know if it's being dragged or scrolled but you won't have the location of the touch.您可以知道它是被拖动还是滚动,但您不会知道触摸的位置。 If you are hesitant about subclassing UIScrollView , you can look at a custom UIGestureRecognizer which will help you keep track of the current location.如果您对子类UIScrollView犹豫不决,您可以查看自定义UIGestureRecognizer ,它将帮助您跟踪当前位置。 Once you have the UITouch object, you can get the location of the tap relative to superview using the locationInView: method.拥有UITouch object 后,您可以使用locationInView:方法获取相对于超级视图的点击位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM