Why interface controller disappears from inside the Page Controller in Apple Watch?

What I found is ?



Try to scroll horizontally between the interface controllers inside a root page controller.



  1. Randomly after a while (30-1 min).
  2. You will find that one of the interface controllers gets missing.
  3. Blank view is shown, UI disappears completely. ( Black view with no interface ).
  4. Try to open the view debugger in XCode, you will find that the Interface window of the view is missing from the page view controller hierarchy.



To reproduce


  • Create a new application.
  • Create a new Watch application
  • Added 2 additional interface controllers to the storyboards
  • Add Identifier for both
  • Inside the initial interface controller call


WKInterfaceController.reloadRootPageControllers(withNames: ["View1","View2"], contexts:  ["View1","View2"], orientation: .horizontal, pageIndex: 1)



  • Run the application on Watch OS 6 Series 3 ( Simulator or A device )
  • Try to scroll randomly



What I expect from the Page controller to hold the interface controllers as it should and it shouldn't show a blank black screen, while the user is scrolling.

Replies

Did I miss something in your design ?


You pass Strings in contexts.

You have to pass references of context objects:


contexts

An array of objects of type

id
. Use this parameter to pass context objects to each of the interface controllers loaded into the page-based interface. The first object in the array is passed to the first interface controller, the second object is passed to the second interface controller, and so on.


context may be the WKInterfaceController themselves.

First of all thanks for your reply.
It was just fast example, but it is an array of strings, since type id is Any so, I can send anything. Objects, Dictionaries, etc. I don't assume that this is the problem. I updated to WatchOS 6.1.2 and it did solve the problem. Also, was able to reproduce on the apple documentation example found here.