Search code examples
iosswiftwatchkitapple-watch-complicationwatchos-3

watchOS 3 app restarts after tapping complication


I have a simple "timer" watchOS app that uses hierarchical navigation. I can press the digital crown to return to the watch Springboard, then tap the app icon and be returned to the same interface controller I was using.

If I return to the watch face and tap my app's complication, the app is launched, but appears to have restarted: I lose my current state. Is there any way to prevent this?


Solution

  • If you open your watch app by tap complication, the app will automatically back to root interface controller(s). This is a system forced behavior.

    If you want to preserve previous state, you need to change your app's hierarchic to page-based interfaces.

    User interaction in page-based interfaces can be just like navigation-based interfaces. You can replace pushController(withName:context:), pop() and popToRootController() methods to becomeCurrentPage(). I also found switch from one page interface to another is also faster than navigation (push/pop) to another.