2014-10-22 63 views
6

我有1主視圖和1個子視圖覆蓋UIGestureRecognizer的touchesBegan

主視圖>子視圖

我認爲,主要觀點是「偷」,從子視圖的事件。

例如,當我在子視圖挖掘,只有主視圖GestureRecognizer很火。

這裏是我的自定義GestureRecognizer(其攔截每一個觸摸事件):

import UIKit 
import UIKit.UIGestureRecognizerSubclass 

class MainGestureRecognizer: UIGestureRecognizer { 

    override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { 
     super.touchesBegan(touches, withEvent: event); 
     //nextResponder() ?? 

     state = UIGestureRecognizerState.Began; 
    } 

    override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) { 
     super.touchesMoved(touches, withEvent: event); 
     //nextResponder() ?? 

     state = UIGestureRecognizerState.Changed; 
    } 

    override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) { 
     super.touchesEnded(touches, withEvent: event); 
     //nextResponder() ?? 

     state = UIGestureRecognizerState.Ended; 
    } 

    override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) { 
     super.touchesCancelled(touches, withEvent: event); 
     //nextResponder() ?? 

     state = UIGestureRecognizerState.Cancelled; 
    } 
} 

也許我應該用nextResponder,但我只找到的OBJ-C代碼,如:

[self.nextResponder touchesBegan:touches withEvent:event];

What's the trick to pass an event to the next responder in the responder chain?

Is there a way to pass touches through on the iPhone?

所以,問題是,我應該做的,使第二個事件(子視圖事件)太火?

在Swift中是否有像nextResponder的功能?

回答