Search code examples
swiftwatchkit

reloadRootPageControllers and deep press


I'm using reloadRootPageControllers() to remove the top left back button.

override func awake(withContext context: Any?) {
    super.awake(withContext: context)

    // Configure interface objects here.
    WKInterfaceController.reloadRootPageControllers(withNames: ["MainController"], contexts: [], orientation: .horizontal, pageIndex: 0)

}

That works, but when I use a deep press (to show 3 choices) I have the following error:

_puic_setViewControllers:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated.

and the thread is freezed.


Solution

  • Don't put the reloadRootPageControllers in the Controller.

    Replace

    pushController(withName: "MainController", context: nil)
    

    By

    WKInterfaceController.reloadRootPageControllers(withNames: ["MainController"], contexts: [], orientation: .horizontal, pageIndex: 0)