首页 > 解决方案 > 从一个接口控制器移动到另一个

问题描述

我试图在接口控制器中有一个倒数计时器,当时间为 0 时,我希望它对下一个接口控制器执行 segue。

有没有办法做到这一点?

    if secondsLeft == 0 {
        pushController(withName: "RunGameInterfaceController", context: nil)

标签: swiftxcodeseguewatchkitwkinterfacecontroller

解决方案


尝试使用 main.storyboard 在两个控制器之间创建一个 segue。

然后,给 segue 一个标识符。这可以在“Storyboard and Segue”选项卡下的右侧栏菜单上完成。

在您的代码中,而不是使用“pushController”

使用“self.performSegue(withIdentifier:“yourSegueName”,发件人:self)”

确保将“yourSegueName”替换为您的标识符,您应该可以开始使用了!


推荐阅读