navigationwatchkitwkinterfacecontroller

Setting the initial view controller in a page based navigation to something other than the first view


In watchOS, I'm implementing a Page-based navigation. The page based navigation contains three interface controllers; however, the first interface controller is the one that shows up first. In my scenario, however, I want the second interface controller to load up first and then they can swipe back/forward to see the other controllers. Is there anyway to implement this functionality?

Approaches tried so far:

Attempt: Connect the interface controllers together using a next page relationship segue and set the Initial interface controller to the second page.

Result: The second interface controller indeed shows up first; however, the first interface controller is completely ignored and you can't scroll back to it.


Solution

  • You just have to insert in your second controller a call to becomeCurrentPage() in the awake method:

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