Reputation: 32986
The following code should work, right?
ViewController2 *childView = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
[self.navigationController pushViewController:childView animated:YES];
[childView release];
It doesn't do anything though. There are no error messages. The view just doesn't get switched. viewDidLoad does not even execute inside ViewController2.
Upvotes: 2
Views: 191
Reputation: 15055
Use this:
[self presentModalViewController:viewControllerNameHere animated:YES];
Upvotes: 0
Reputation: 27591
That code won't do anything if the view controller presenting it doesn't have a navigation controller, i.e. it isn't in a navigation controller stack. In that case, you'll be calling a method (pushViewController:animated:
) on a nil object (self.navigationController
) which does nothing. Thus, you can only use this this method if the "parent" view controller is in a UINavigationController
stack.
Upvotes: 1