UIScrollview 触摸
我有一个 UIScrollView 实例,允许用户放大/缩小。我已经根据文档实现了一个委托来处理这个问题。但是,我想知道用户触摸滚动视图的位置(相对于滚动视图的超级视图的框架)。我可以拦截此信息,例如通过滚动视图的某些属性,而不覆盖 touchesMoved:withEvent:
吗?
[UIScrollView
实例在内部根据它们收到的触摸类型做出决定。我不想模仿这个,我想知道这个决定和触摸的位置。]
I have an instance of UIScrollView
which I'm allowing the user to zoom in/out. 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:
?
[UIScrollView
instances internally make a decision on the type of touch they received. I don't want to emulate this, I'd like to know the decision and the location of the touch.]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
滚动视图中没有任何属性可以告诉您触摸的位置。您可以知道它是否被拖动或滚动,但您无法知道触摸的位置。如果您对子类化
UIScrollView
犹豫不决,您可以查看自定义UIGestureRecognizer
,它将帮助您跟踪当前位置。获得UITouch
对象后,您可以使用locationInView:
方法获取相对于超级视图的点击位置。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 customUIGestureRecognizer
which will help you keep track of the current location. Once you have theUITouch
object, you can get the location of the tap relative to superview using thelocationInView:
method.