UIScrollview 触摸

发布于 2024-11-11 17:51:36 字数 245 浏览 6 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生不灭 2024-11-18 17:51:36

滚动视图中没有任何属性可以告诉您触摸的位置。您可以知道它是否被拖动或滚动,但您无法知道触摸的位置。如果您对子类化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 custom UIGestureRecognizer which will help you keep track of the current location. Once you have the UITouch object, you can get the location of the tap relative to superview using the locationInView: method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文