Search code examples
iosapple-watch

How do you create and index Apple Watch interface pages


I'm creating a watch app that has multiple pages using the same interface controller. I would like to know how my custom manager object can index each controller.

I've tried adding a IBInspectable index set in the storyboard, but the controllers report their pageIndex as 0 after init & awake calls.

I know I could create subclasses that return their own index, but that seems messy.


Solution

  • You have no control on the index, is just a matter of adding them to an array in the order you want.

    This is how you present pages:

    [self presentControllerWithNames:controllers contexts:contexts];
    

    Both controller and contexts are arrays. The pages will be presented with the order they have in the array.

    If you will present multiple controllers of the same type, create a for loop and add them to the controller array. The same with the contexts.

    controllers[0] will use the contexts[0] and so on.