chrishomer
chrishomer

Reputation: 4920

How do I push a view controller from a custom view action using storyboards/IB?

I have a navigation controller than manages a view with a custom component that does not show up on the storyboards/interface builder. When I trigger a particular action, I would like to push on the next view controller. I can do this in code, but I would like to stick to storyboards as much as possible. Is there a way to establish this link?

Thanks

Upvotes: 1

Views: 233

Answers (1)

polarware
polarware

Reputation: 2519

Use prepareForSegue in your (root) view controller:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"SeguName"]) {
        UINavigationController * navigationController = segue.destinationViewController;
        PlayerDetailsViewController * playerDetailsViewController = [[navigationController viewControllers] objectAtIndex:0];
        playerDetailsViewController.delegate = self;
    }
}

Upvotes: 2

Related Questions