嗨,我已经多次尝试通过使用教程来连接到另一个 View Controller ,但它们不起作用。请有人给我关于如何设置和调用 Segue 到下一个 View Controller 的明确说明。请记住,此代码不会位于当前 View Controller 类中。
该函数在我的玩家死亡时运行,因此我希望出现另一个 View Controller 。其功能是:
func playerHitSquare(player:SKSpriteNode, level1: Enemy){
timer.invalidate()
removeAllChildren()
}
我想要访问的 View Controller 名为 FinishViewController,其标识符为 Finish,当前 View 为 GameViewController。
最佳答案
如果您使用导航 Controller ,则可以调用
func popViewControllerAnimated(_ animated: Bool) -> UIViewController?
删除当前的 VC,然后
func pushViewController(_ viewController: UIViewController, animated animated: Bool)
将所需的 View Controller 添加到导航堆栈并使其处于事件状态。请记住,您可能需要向 View Controller 类的 viewDidLoad 或 viewDidAppear/viewDidDisappear 添加代码,具体取决于
关于ios - Swift 在函数中连接到另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39538584/