我在子视图控制器中开始重写触摸,我将它们发送到根视图控制器,如下所示:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
println("touchesBegan CardItemController")
var root = self.navController?.viewControllers[0] as! MainViewController
root.touchesBegan(touches, withEvent: event)
}
我已经检查过是否在父视图控制器中调用了touchesBegan,如下所示:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
println("touchesBegan MainViewController")
}
它被调用但是在根视图控制器的另一个子视图中没有调用touchesBegan ...在根目录中我将CardItemController作为子视图以及另一个首先添加的子视图。
我已尝试将触摸开始发送到根视图控制器的子视图中,如下所示:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
println("touchesBegan MainViewController")
mainView.touchesBegan(touches, withEvent: event)
}
但这似乎只是创建了一个永无止境的循环并使应用程序崩溃。我在这里做错了什么?