我遇到了一个非常奇怪的事情: 在storyboard中有ViewControllers:1stVC和2ndVC, 在1stVC(故事板中的初始VC)中只有2个函数:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
//when touch view in 2ndVC,it will exec here!!!
super.touchesBegan(touches, with: event)
NSLog("xxx")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//switch to 2ndVC
performSegue(withIdentifier: "2ndVC", sender: nil)
}
因为app从1stVC开始,但是在viewDidAppear func它很快就会去exec performSegue()func切换到2ndVC;现在app应该在2ndVC,但是当我触摸屏幕时(在2ndVC的视图中),它会跳转到1stVC的touchsBegin func(exec NSLog(“xxx”))。
怎么会发生这种情况!?请帮帮我,谢谢!