我有一个主视图和一个SubView
主视图> SubView
我认为主要观点是“窃取”SubView的事件。
例如,当我点击SubView时,只有主视图GestureRecognizer是fire。
下面是我的自定义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代码:
self.nextResponder触控贝根:触碰事件:事件; 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?
所以问题是,我应该怎么做才能让第二个事件( SubView事件)也发生呢?
在Swift中有像nextResponder这样的函数吗?
发布于 2014-10-22 16:46:17
快跳啊!以下是nextResponder的Swift代码:
https://stackoverflow.com/questions/26506148
复制相似问题