Iphone:检测从按钮开始的拖动/滑动方向

发布于 2024-09-24 00:51:41 字数 159 浏览 0 评论 0原文

我试图为可能有按钮的视图制作一个滑动机制。如果没有按钮,那就小菜一碟了。

但是,如果您的手指从按钮上开始,您可以触发一个事件(拖动到外面),但这并不能告诉我方向。

那么,如何检测手指在按钮上开始滑动/拖动的方向呢?

有什么想法吗?

谢谢西蒙

I trying to make a swipe mechanism for a view that might have buttons on it. Without a button its a piece of cake.

However if your finger starts on the button, you can trigger an event (drag outside) but that does not tell me the direction.

So how can I detect the direction of a swipe / drag where your fingers starts on a button?

Any ideas?

Thanks Simon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

扎心 2024-10-01 00:51:41

只要不使用外部拖动事件,这仍然很容易。查看 UIView 中的 hitTest:withEvent 以确定它是否在按钮中启动。与 UISwipeGestureRecognizer (或触摸事件的东西)一起,你应该没问题。

It's still easy you just don't use the drag outside event. Look at the hitTest:withEvent in UIView to determine if it starts in the button or not. Along with UISwipeGestureRecognizer (or the touch event stuff) you should be fine.

睡美人的小仙女 2024-10-01 00:51:41

查看UISwipeGestureRecognizer。您应该能够将其添加到主视图中,并让它识别手势,无论它是否源自按钮。

Check out UISwipeGestureRecognizer. You ought to be able to just add it to your main view and have it recognize the gesture whether or not it originates on a button.

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