在watchOS上以编程方式触发segue

Chr*_*son 0 ios apple-watch swift3 watchos-3

我正在研究watchOS 3应用。

我有一个segue挂在按钮上,并且工作正常。现在,我想以编程方式触发它。

从电话收到消息后,我想将手表导航到特定视图,但似乎无法self.performSegue通过WatchKit 调用method。

有什么办法吗?

erg*_*oon 5

在WatchKit中,您无法以编程方式执行segue。相反,你需要使用pushController(withName:context:)presentController(withName:context:)presentController(withNames:contexts:)

确保在InterfaceBuilder中为WKInterfaceControllers设置标识符。

如果您需要将数据传递给控制器​​,请查看contextForSegue(withIdentifier: String) contextsForSegue(withIdentifier: String)