In the appDelegate,I create a A_NavigationController to become self.window.rootViewController,and set a X_ViewController to become the rootViewController, after an other viewController pushed,I create a new B_NavigationController ,seted a new Y_ViewController to become the rootViewController and used presentModalViewController method ,added the B_NavigationeController. Now I want to do is,when I dismissed the Y_ViewController can change the A_NavigationController’s rootViewController.
self.viewController = [[AViewController alloc] initWithNibName:@"AViewController" bundle:nil];
self.navCon=[[UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = self.navCon;
BViewController *bView=[[BViewController alloc]initWithNibName:@"BViewController" bundle:nil];
UINavigationController *navCon=[[UINavigationController alloc]initWithRootViewController:bView];
[self.navigationController presentModalViewController:navCon animated:YES];
//in BViewController.m
//I want a method to change the window's rootViewController.
The “rootViewController” is only the UIViewController on the bottom of the navigationStack. To change it you can just set the object at index 0 to whatever controller you want