为什么触及1stVC触发来自2ndVC触摸的开始事件?

时间:2017-10-02 13:46:15

标签: swift xcode uiviewcontroller segue touches

我遇到了一个非常奇怪的事情: 在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从1st​​VC开始,但是在viewDidAppear func它很快就会去exec performSegue()func切换到2ndVC;现在app应该在2ndVC,但是当我触摸屏幕时(在2ndVC的视图中),它会跳转到1stVC的touchsBegin func(exec NSLog(“xxx”))。

怎么会发生这种情况!?请帮帮我,谢谢!

0 个答案:

没有答案