Search code examples
iosobjective-cwatchkit

pushControllerWithName not working


I'm trying to push an interface controller with the identifier "InterfaceControllerTodoItemTapped" programmatically (deployment target iOS 8.2) when a WKInterfaceTable row is tapped:

[self pushControllerWithName:@"InterfaceControllerTodoItemTapped" context:nil];

The source controller is part of a page-based navigation setup.

The identifier field of the receiving interface controller is set to "InterfaceControllerTodoItemTapped".

Problem: Although the above push command is reached (confirmed using a breakpoint), the InterfaceControllerTodoItemTapped is not shown and its method awakeWithContext is not being called (confirmed using a breakpoint).


Solution

  • Apple's documentation states that one has to choose either a page-based or a hierarchical navigation. They are mutually exclusive.

    Therefore, presenting a controller using pushControllerWithName does not work with page-based navigation.

    The solution is to present the controller modally using the following method:

    [self presentControllerWithName:@"InterfaceControllerTodoItemTapped" context:nil];