watchkitwatchoswkinterfacecontroller

watchOS app resets to root view controller after display sleep


I'm implementing a simple hierarchical interface for a watchOS app, using pushController(withName: String, context: Any?) to add views onto the stack. When trying to test on a watchOS 3 device, my app will reset itself back to the root view controller, losing the navigation state, after a "sleep" event.

Is this expected behavior? I would expect the navigation state to reset if the app was purged from memory, but not after the screen goes to sleep.


Solution

  • Setting the app target to watchOS 3 and implementing the handle(_:) WKExtensionDelegate method (which I had not done, since the watchOS targets were generated under Xcode 7) seems to provide the behavior I expected.