Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Watch Kit How Do You Present A Page Programmatically

Tags:

watchkit

In a watch app how do you change page programmatically?

I've got 3 WKInterfaceControllers in a page based app and I want to change from one page to another when a user presses a table view cell.

I can present a view controller modally fine but when I try to push the view controller or hook the segue up to the cell controller, nothing happens.

like image 536
Mark Bridges Avatar asked Mar 07 '15 21:03

Mark Bridges


1 Answers

You won't be able to push an interface controller since you're building a page-based app. The only option that you have is to use the WKInterfaceController becomeCurrentPage method on the interface controller you want to switch to. It needs to be one of the three interface controllers already loaded into the page set.

Since you don't actually have a reference to the interface controller that you need to switch to from the table interface controller, you'll need to use a system such as NSNotificationCenter to send a notification to the interface controller that you need to becomeCurrentPage.

This should allow you to switch from one interface controller to another when tapping on a table row.

like image 152
cnoon Avatar answered Oct 17 '22 10:10

cnoon