在Apple Watch的"ExtensionDelegate"中设置rootInterfaceController

mar*_*oum 7 storyboard ios apple-watch wkinterfacecontroller

我正在制作一个Apple Watch应用程序,我想根据初始条件设置不同的根视图控制器.

我不能直接设置WatchKit rootInterfaceController,因为它是一个只读属性,但通过检查Apple文档,他们说可以"在启动序列完成之前"设置它.

你有一个很好的建议去做吗?也许通过故事板?

Lio*_*ion 1

您不能设置只读属性,您可以执行类似的操作,

创建一些 SplashController,带有一些闪屏,然后在awakeWithContext

 override func awakeWithContext(context: AnyObject?) {
      super.awakeWithContext(context)
 }
Run Code Online (Sandbox Code Playgroud)

跟踪你需要的东西,在跟踪呈现一些控制器之后,例如

   if !isCounting {
    self.presentControllerWithName("Interface", context: nil)
} else {
    self.presentControllerWithName("Timer", context: nil)
}
Run Code Online (Sandbox Code Playgroud)

isCounting存储在 NSUserDefaults 中

希望这会有所帮助:)