sandy
sandy

Reputation: 386

Start hierarchical navigation from page based navigation in watchkit extension

The Apple Watch programming guide points that you can not mix page based navigation and hierarchical navigation.

My apple watch app starts with a Maininterfacecontroller in hierarchical navigation and depending upon the availibility of related data, it starts page based navigation using reloadRootControllersWithNames of WKInterfaceController.

Now in page based navigation,When I have no related data to display, I want to end page based navigation and start hierarchical navigation with Maininterfacecontroller again.

Upvotes: 4

Views: 460

Answers (1)

Duncan Babbage
Duncan Babbage

Reputation: 20187

As Apple's Interface Navigation documentation states, page based navigation and hierarchical navigation are mutually exclusive. You are interpreting this to mean that you can't interleave them at the same time, but that is not what Apple are saying. Rather, you must decide on one of these base navigation styles for your WatchKit App and that will be the base navigation style for that app build. You cannot change it programmatically. (The one work-around to this is that you can display a modal view on top of your base navigation style, and that modal view can use a different navigation style.)

Your description, however, suggests that you are not actually doing what yo think you are. reloadRootControllersWithNames(_:contexts:) is a method available only within a page based interface. Therefore, what your app is doing is launching with a page based interface and then displaying a particular set of pages based on a user selection.

Most likely, this confusion has arisen because when you first load your page-based interface, you have loaded a single interface controller. With only a single page in your initial set, which may be formatted to contain a number of buttons and thus look like a hierarchical controller, you are concluding that you are using a hierarchical interface type when you are not.

Given all that is the case, to return to that original interface controller from your pages, you simply need to again call reloadRootControllersWithNames(_:contexts:) and pass it the name of your original interface controller that you launch with.

Upvotes: 1

Related Questions