watchkitwatchospagecontrol

How to add Page Control in watch application


I have seen several apps that is using page control to navigate among screens in watch application. But I wonder how can we add that control in watch interface. Please help.


Solution

  • Use WKInterfaceController.reloadRootPageControllers for this.

    Here is example:

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

    Call this method to create or modify your app’s page-based interface: At launch time. Use this method to customize the set of pages you want displayed, and to set the scrolling orientation. At runtime. Use this method to change the active set of pages or the orientation, adding or removing pages as needed.

    NOTE: It's not recommended to uses both navigation types: pages and modal at the same time.