简体   繁体   中英

How to change initial controller in WatchKit app?

In my WatchKit app I need to display one of two interface controllers depending on the state of the containing iOS app. Neither Page-Based nor Hierarchical interfaces suit my needs.

In UIKit I can change rootViewController of the window. Can I do similar trick in the WatchKit?

Is there a way to programmatically switch to a different interface controller without animation and make it the "initial controller"?

let rootControllerIdentifier = "FirstInputInterfaceController"

WKInterfaceController.reloadRootControllers(withNames: [rootControllerIdentifier], contexts: nil)

If there are only 2 Interface Controllers in your app, then you can use Groups, and show one group at a time, and hide other based on your conditions.

At run-time, the only way to modify the arrangement of items is to show/hide elements that you already added using interface builder.

Hope this helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM