WatchKit reloadRootControllersWithNames causing error, with pageController or after push/pop

大城市里の小女人 提交于 2019-11-29 02:11:51

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

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!

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.

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?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!