2015-03-02 31 views

回答

0

如果有問題的按鈕是UIButton,您可以通過向從UIControl繼承的UIButton註冊2個不同的選擇器來完成此操作。

[_theButton addTarget:self action:@selector(mySelectorBeforeAction:) forControlEvents:UIControlEventTouchDown]; 
[_theButton addTarget:self action:@selector(mySelectorAfterAction:) forControlEvents:UIControlEventTouchUpInside]; 

UIControlEventTouchCancel:系統事件取消當前控件的觸摸。

UIControlEventTouchDown:控件中的觸發事件。

UIControlEventTouchDownRepeat:控件中的重複觸發事件;對於此事件,UITouch tapCount方法的值大於1。

UIControlEventTouchDragEnter:手指被拖入控件邊界的事件。

UIControlEventTouchDragExit:手指從控件內拖動到其界限外的事件。

UIControlEventTouchDragInside:手指在控件邊界內拖動的事件。

UIControlEventTouchDragOutside:手指在控件邊界之外被拖動的事件。

UIControlEventTouchUpInside:手指位於控件邊界內的控件中的觸摸事件。

UIControlEventTouchUpOutside:控件中手指位於控件邊界之外的觸控事件。

相關問題