Iphone:检测从按钮开始的拖动/滑动方向
我试图为可能有按钮的视图制作一个滑动机制。如果没有按钮,那就小菜一碟了。
但是,如果您的手指从按钮上开始,您可以触发一个事件(拖动到外面),但这并不能告诉我方向。
那么,如何检测手指在按钮上开始滑动/拖动的方向呢?
有什么想法吗?
谢谢西蒙
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要不使用外部拖动事件,这仍然很容易。查看 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.查看
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.