This is not how UINavigationControllers
work. You need to set A as the rootViewController
of your UINavigationController
. UINavigationController is a container for other view controllers.
For example, in your AppDelegate
you might do something like this:
UIViewController *A = [[UIViewController alloc] init];
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:A];
UIViewController *X = [[UIViewController alloc] init];
UIViewController *Y = [[UIViewController alloc] init];
UIViewController *Z = [[UIViewController alloc] init];
UITabBarController *tabVC = [[UITabBarController alloc] init];
tabVC.viewControllers = @[X, Y, Z, navVC];
self.window.rootViewController = tabVC;
And in A
- (IBAction)pressButton:(id)sender
{
[self.navigationController pushViewController:B animated:YES];
}
from
stack overflow
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set the view controller as the window's root view controller and display.
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
employeeDetailed = [[[EmployeeDetailedViewController alloc] initWithNibName:@"EmployeeDetailedViewController" bundle:nil] autorelease];
[self. navigationController presentModalViewController: navController];
add uinavigationcontroller to uiviewcontroller
self.navigationItem.title=@"Diary Love"; a