WatchKit reloadRootControllersWithNames causing er

2020-02-09 11:57发布

问题:

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.

回答1:

This is actually not a bug because according to Apple:

You cannot combine hierarchical and page-based interface styles. At design time, you must choose the style that best suits your app’s content and design for that style.

So unfortunately, we can't mix Hierarchical and Page-based navigation patterns within the same Watch app.

Just one of many limitations we have to deal with when developing apps for  Watch



回答2:

This is a bug in WatchKit in Xcode 6.2 Beta 5. Please dupe the following radar on Apple's Bug Reporting System to help raise the priority to get this fixed.

In the meantime, a workaround that I've found can be found on the dev forums. What you can do is add a dummy interface controller to any single interface controller page set so you always have two. This will fix the error until Apple get's the bug fixed (hopefully in Beta 6). Please dupe!



回答3:

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:

  1. Push a view controller
  2. reloadRootControllersWithNames to return to the original controller. (The transition is not quite as animated, but is sufficient)
  3. Create page based view controller.
  4. reloadRootControllersWithNames to return to the original controller
  5. 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.



回答4:

None or the answers above worked for me. This problem began when I changed the icon names for the app and the watch app name. I solved it like this:

  • 1) Click on your Watch app Target > Capabilities > make sure app Group is in ON.
  • 2) Make sure the App Group is selected.
  • 3) Clic on the circled arrow Refresh icon (this will apparently just refresh this thing if you already had it)
  • 4-Repeat steps 1-3, but for your Watch App EXTENSION target too.
  • 5-Click on the Scheme button (on the right side of the STOP button), and clic on Edit Schemes.
  • 6-Click Run > Info 7-In executable select your target (Actually it should already be selecting but opening this window seems to refresh the option, and wipe the error)

Apparently all these things above are not updated automatically when you change the icon name (Target names) and you have to go to those menus and open them to refresh them manually. Shame on Apple perhaps?



标签: ios watchkit