简体   繁体   中英

How to add a New Page in code to Page-Based Navigation Apple Watch

I have a page based app. 1st page shows number of timers with a "add timer" button. When they click that button i want to append a new page with a new timer. Then the user can swipe the left to see all the timers or back to the first page by swiping right to view the count and add another.

Right now I know I can set page based manually in story board and I know I can presentControllerWithNames in my root interface controller but that creates a double load since it first loads the interface controller then executes the presentControllerWithNames.

Any suggestions??

WKInterfaceController has a class method: class func reloadRootControllersWithNames(names: [AnyObject]!, contexts: [AnyObject]!) to reload all pages.

Just call it in your button's action method:

WKInterfaceController.reloadRootControllersWithNames(["theFirstController", "theNewTimerController"], contexts: someContexts)

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