Search code examples
iosobjective-cwatchkit

Return to Previous WatchKit Interface Controller


I have an interface controller that goes to another interface controller when a button is pressed. I do it like this

- (IBAction)setLocationPressed {
    [self pushControllerWithName:@"setLocation" context:self.appContext];
}

How can I return to the first controller when a button on the second one is pressed?


Solution

  • If you check out the documentation for WKinterfaceController (https://developer.apple.com/library/prerelease/ios/documentation/WatchKit/Reference/WKInterfaceController_class/index.html#//apple_ref/occ/instm/WKInterfaceController/popController) you'll see two methods that are relevant to what you want to do: popController and popToRootController.