Search code examples
iosuiviewcontrollerstoryboardxib

Having trouble calling a ViewController with .xib file from storyboard in iOS


I have an application where I have a ViewController in my storyboard file. I have added a button to this viewController that should call another ViewController that is outside of the storyboard and has with it, it's own .xib file. However, when I press this button, the method is being called, but the new screen is not being loaded, and I don't know why.

Here is the relevant code that I have below:

- (IBAction)showTireCount:(id)sender {

    NSLog(@"do i get called?");
    SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    [self.navigationController pushViewController:secondView animated:YES];

}

I am able to see the text "do i get called" appear in the system output, but unfortunately nothing else occurs. Can anyone see what it is I am doing wrong?


Solution

  • self.navigationController is nil. Did you embed your view controller (the one with the button) in a UINavigationController?