在watchKit中更改初始接口控制器

Pav*_*kyy 6 ios swift apple-watch watchkit

我有两个接口控制器,controller1.swiftcontroller2.swift

它们与push-segue连接(按钮动作后).但在某些情况下,我需要跳过controller1并显示controller2.在iOS应用程序中,我执行此操作appDelegate,设置rootViewcontroller等.在Apple Watch Extension中执行此操作的方法是什么?

任何指南或帮助?

Abh*_*yam 7

let rootControllerIdentifier = "FirstInputInterfaceController"

WKInterfaceController.reloadRootControllers(withNames: [rootControllerIdentifier], contexts: nil)
Run Code Online (Sandbox Code Playgroud)

斯威夫特4:

let rootControllerIdentifier = "FirstInputInterfaceController"
WKInterfaceController.reloadRootControllers(withNamesAndContexts: [(name: rootControllerIdentifier, context: [:] as AnyObject)])
Run Code Online (Sandbox Code Playgroud)


Pav*_*kyy 1

经过长时间的研究工作,我只找到了一种解决方案 - 创建一些 SplashController,带有一些闪屏,然后在

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)

希望它能帮助某人。PS isCounting 存储在 NSUserDefaults 中