2012-09-29 28 views
0

例如,我有一個按鈕,當點擊這個按鈕時,它會調用一個動作:doAction1。 而一個視圖:當觸摸它時,它會調用一個動作doAction2。如何在iPhone中設置操作的優先級?

點擊這個按鈕的時候,也觸動了。 它有任何屬性來設置優先級調用doAction1或doAction2?

+2

是的,你可以優先採取行動。我建議使用[NSOperation](http://developer.apple.com/library/ios/#documentation/cocoa/Reference/NSOperation_class/Reference/Reference.html)和NSOperationQueue來管理您需要能夠進行的後臺活動任意取消並設置優先級。請參閱[線程編程指南](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html) – Bala

+0

謝謝。巴拉。 – cat

回答

1

我假設你你把Tapgesturerecogniyer到容器view.You可以忽略點擊手勢,如果用戶已拍了拍button.Just覆蓋嘴硬方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 
// test if touched view is unbutton 

    if ([touch.view isKindOfClass:[UIButton class]]) 
    { 

     return NO; // ignore the touch 
    } 

return YES; 

}