Reputation: 3709
I want to call secondview from my current view but this code suggested by someone is not working properly
UINavigationController *nav=[[UINavigationController alloc] initWithNibName:@"Second" bundle:[NSBundle mainBundle]];
[nav pushViewController:@"Second" animated:YES];
Upvotes: 1
Views: 148
Reputation: 35171
I suggest you put naviagtionbar initialization in your application:didFinishLaunchingWithOptions:
if it's your rootViewController. You can initiate it with rootViewController, like so:
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:firstViewController_1];
self.window.rootViewController = nav;
[nav release];
Push other views in your view controller(e.g. your FirstViewController.m):
SecondViewController * secondViewController_2 = [[[NSBundle mainBundle] loadNibNamed:@"SecondViewController" owner:self options:nil] lastObject];
// Or: SecondViewController * secondViewController_2 = [[SecondViewController alloc] init...] autorelease];
[self.navigationController pushViewController:secondViewController_2 animated:YES];
Upvotes: 1
Reputation: 7340
Why are you pushing an NSString
onto a UINavigationController
? I think what you want is:
SecondView * vc = [[SecondView alloc] initWithNibNamed:@"SecondView"];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
Hope that Helps!
Upvotes: 2
Reputation: 62
hope this will help you.
[self.navigationController presentModalViewController:SecondView animated:YES];
Upvotes: 1