【问题标题】:change initial interface controller in watchKit更改 watchKit 中的初始接口控制器
【发布时间】:2015-06-11 11:26:54
【问题描述】:
我有两个接口控制器,controller1.swift 和 controller2.swift
这些与 push-segue 连接(在按钮操作之后)。但在某些情况下,我需要跳过controller1,只显示controller2。在 iOS 应用程序中,我在 appDelegate 中执行此操作,设置 rootViewcontroller 等。在 Apple Watch Extension 中执行此操作的方法是什么?
任何指南或帮助?
【问题讨论】:
标签:
ios
swift
watchkit
apple-watch
【解决方案1】:
let rootControllerIdentifier = "FirstInputInterfaceController"
WKInterfaceController.reloadRootControllers(withNames: [rootControllerIdentifier], contexts: nil)
斯威夫特 4:
let rootControllerIdentifier = "FirstInputInterfaceController"
WKInterfaceController.reloadRootControllers(withNamesAndContexts: [(name: rootControllerIdentifier, context: [:] as AnyObject)])
【解决方案2】:
经过长时间的研究工作,我发现只有一个解决方案 - 创建一些 SplashController,带有一些闪屏,并在
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
}
跟踪你需要的东西,在跟踪后出现一些控制器,示例
if !isCounting {
self.presentControllerWithName("Interface", context: nil)
} else {
self.presentControllerWithName("Timer", context: nil)
}
希望它会帮助某人。
附言isCounting 存储在 NSUserDefaults 中