我有一个基本的 watchkit 应用程序,可以加载 3 个界面 Controller 的基于页面的导航。这很好用,但我想触发一个操作来删除页面控件,并基本上恢复到应用程序首次加载时存在的原始 InterfaceController。
// 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:@[@{}]];
基于页面的导航移除,原始导航在短旋转后加载。但是它无法正常运行,原始操作会导致此错误。
Extension[6766:123665] *********** ERROR
-[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found
有没有更好的方法来干净地重新加载原始的 InterfaceController?
编辑,2/19
似乎还有其他一些操作也会导致此错误。例如,如果转到第二个 InterfaceController 然后 popController 返回,则经常会出现错误。它始终与对此函数的二次调用有关。
[WKInterfaceController reloadRootControllersWithNames: contexts:]
EDIT2,3 月 18 日
如前所述,通过执行 seguePush、popController,然后尝试重新加载 RootControllersWithNames,这在 100% 的时间内是可重现的。
如果 seguePush/popController 没有事先完成,那么 reloadRootControllersWithNames 将正常工作。
这种情况似乎是这个bug的多>单多实例的补充。
最佳答案
这实际上不是错误,因为根据 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.
很遗憾,我们不能在同一个 Watch 应用中混合使用分层和基于页面的导航模式。
这只是我们在为 Watch 开发应用时必须处理的众多限制之一
关于ios - WatchKit reloadRootControllersWithNames 导致错误,使用 pageController 或在 push/pop 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28596405/