Reputation: 61616
I have 2 XIBs with their corresponding View Controllers. Will call them MainViewController and AboutViewController. The names of the XIBs are exactly the same as the names of the ViewControllers. Upon a button click in the MainViewController, I want to show the AboutViewController.
I have code like this in the MainViewController:
- (IBAction) infoButtonAction:(id)sender {
AboutViewController *aboutViewController = [[AboutViewController alloc] init];
[[self navigationController] pushViewController:aboutViewController animated:YES];
}
But nothing happens, the AboutViewController does not show up. I also tried this line:
AboutViewController *aboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
But to no avail. What am I missing?
Upvotes: 0
Views: 499
Reputation: 28600
Examine your AboutViewController.xib in Interface Builder and ensure that the File Owner is set to AboutViewController
in the class inspector. Also ensure that the view
property of the File Owner is wired into the View in the xib. Finally, the code to display it should read:
- (IBAction) infoButtonAction:(id)sender {
AboutViewController *aboutViewController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
[[self navigationController] pushViewController:aboutViewController animated:YES];
[aboutViewController release];
}
Also, you should check that this is non-nil inside that same method:
UINavigationController * nc = self.navigationController;
Upvotes: 1
Reputation: 46965
do you get an error? Did you check that the button is correctly wired in IB?
did you try using a modal view controller?
Upvotes: 0