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?
所以,问题是,我应该做的,使第二个事件(子视图事件)太火?
在Swift中是否有像nextResponder的功能?
你介意张贴一些代码?我无法弄清楚这个链接如何适合解决你的(和我的)问题。 – Suragch 2015-10-05 05:09:04