WatchKit reloadRootControllersWithNames causing error, with pageController or after push/pop
ios, watchkit
Solution
I was able to solve my instance of this problem by not using popController on a pushed view controller. Instead I use a reloadRootControllersWithNames in place of the popController.
How this allows both push and paging, via an example:
- Push a view controller
- reloadRootControllersWithNames to return to the original controller. (The transition is not quite as animated, but is sufficient)
- Create page based view controller.
- reloadRootControllersWithNames to return to the original controller
- Repeat 1 or 3 as needed.
This eliminates the error at the cost of non-animated popControllers, and allows partial pushing and paging. It would not allow more complex push navigation though.
There may be a better method of navigating to a sub interface controller without a push call, but I'm not aware of it on the watch yet.
Problem
I have a basic watchkit app that loads a page based navigation of 3 interface controllers. This works well, but I'd then like to trigger an action to remove the page-control and essentially revert back to the original InterfaceController that was present when the app first loads. ``` // load page based control, with 3 views. this works ok [WKInterfaceController reloadRootControllersWithNames:@[@"pageController1",@"pageController2",@"pageController3"] contexts:@[@"data1",@"data2",@"data3"]]; // attempt to reload original interface controller, identified by storyboard id [WKInterfaceController reloadRootControllersWithNames:@[@"myInterfaceController"] contexts:@[@{}]]; ``` The page based navigation remove, the original navigation loads after a short spinner. However it fails to function correctly and original Actions result in this error. ``` Extension[6766:123665] *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found ``` Is there a better way to cleanly reload the original InterfaceController? EDIT, 2/19 It seems there are some other actions that are causing this error too. For instance, if segue to a second InterfaceController and then popController to get back, the error often appears. It is always related to a secondary call to this function. ``` [WKInterfaceController reloadRootControllersWithNames: contexts:] ``` EDIT2, 3/18 As previously mentioned, this is reproducible 100% of the time by doing the seguePush, the popController, then attempting to reloadRootControllersWithNames. If the seguePush/popController is not done beforehand, then the reloadRootControllersWithNames will work fine. This situation seems to be in addition to the multi->single-multi instance of this bug.