好的,我有一个应用程序,它从一个菜单视图控制器开始,它会提示用户按下4ish按钮中的一个,然后加载一个视图控制器,然后显示一个场景,用户根据按下的按钮玩游戏。
然后我让用户被重定向到另一个视图控制器,显示另一个场景,一旦满足了一个条件(他们输了游戏)。
此外,我在我的旧游戏中有音频播放,它目前仍在播放。我并不介意,因为稍后我将在所有3个视点控制器和它们所呈现的场景之间传递音频数据(全部静音)。
现在发生的唯一问题是,当我运行应用程序时,因为旧的viewiewcontroller和它的场景似乎仍然在下面运行,它一直在调用转换,这会导致一个奇怪的外观,当条件满足时,转换会无休止地循环到新的视图控制器,然后返回到转换的开始,然后再返回到新的视图控制器。
我试过这段代码:
let theVC = self.viewController?.storyboard?.instantiateViewController(withIdentifier: "TrumpVC") as! TrumpViewController
self.viewController?.navigationController?.pushViewController(theVC, animated: true)
self.viewController?.dismiss(animated: true, completion: {});但它似乎一点帮助都没有:(基本上我导航到一个新的视图控制器并关闭当前的视图控制器(这都在我的场景中)
谢谢
发布于 2017-02-06 01:31:02
解决方案:
let theVC = self.viewController?.storyboard?.instantiateViewController(withIdentifier: "TrumpVC") as! TrumpViewController
self.viewController?.navigationController?.pushViewController(theVC, animated: true)
self.viewController?.removeFromParentViewController()
self.viewController?.dismiss(animated: true, completion: nil)
self.view?.presentScene(nil)https://stackoverflow.com/questions/42054381
复制相似问题