如何识别拖动动作 [英] How do you recognize drag gestures
问题描述
我有几个按钮,在我看来,建立了使用IB。每个按钮触发一个简短的音频声音。
I have several buttons in my view built using IB. Each button triggers a short audio sound.
我希望能够拖我的手指在他们触发他们......就像你拖动你的手指在钢琴键(不要担心我不是钢琴应用程序)
I want to be able to drag my finger over them to trigger them... just like you are dragging your finger over piano keys (don't worry I am not making a piano app)
我无法弄清楚如何识别按钮外,然后里面淡淡的。
I cant figure out how to recognize a touch outside the button and then inside it.
任何想法?
感谢
推荐答案
由于从UIControl你的按钮子类,你可以用UIControl的实现手势识别的。
As your buttons subclass from UIControl, you can use UIControl's implementation of recognition of gestures.
看UIControl的 - (无效)addTarget:(ID)目标的行动:(SEL)动作forControlEvents:(UIControlEvents)controlEvents
。这将让你无论何时指定某些事件发生时被称为对象的方法。可能的事件,其中包括:
Look at UIControl's - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
. This will let you specify a method on an object to be called whenever certain events occur. The possible events are, among others:
UIControlEventTouchDragInside = 1 << 2,
UIControlEventTouchDragOutside = 1 << 3,
UIControlEventTouchDragEnter = 1 << 4,
一个完整列表可在苹果的<一个href=\"http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIControl%5FClass/Reference/Reference.html#//apple%5Fref/doc/constant%5Fgroup/Control%5FEvents\"相对=nofollow>为控制事件文档。
A complete list is available in Apple's documentation for Control Events.
在 UIControlEventDragOutside
火灾,你可能需要重新评估其观点正在播放。
When UIControlEventDragOutside
fires, you may want to reevaluate which view is currently playing.
这篇关于如何识别拖动动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!