1

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.

Any ideas?

Thanks

4

1 回答 1

4

作为 UIControl 的按钮子类,您可以使用 UIControl 的手势识别实现。

看看 UIControl 的- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents. 这将允许您指定在发生某些事件时要调用的对象的方法。可能的事件包括:

   UIControlEventTouchDragInside     = 1 <<  2,
   UIControlEventTouchDragOutside    = 1 <<  3,
   UIControlEventTouchDragEnter      = 1 <<  4,

Apple 的Control Events 文档中提供了完整列表。

触发时UIControlEventDragOutside,您可能需要重新评估当前正在播放的视图。

于 2009-08-28T05:31:32.723 回答