在appDelegate中,我创建一个A_NavigationController成为self.window.rootViewController,并设置一个X_ViewController成为rootViewController,在推送其他viewController之后,我创建一个新的B_NavigationController,设置一个新的Y_ViewController成为rootViewController并使用presentModalViewController方法,添加了B_NavigationeController。现在我想做的是,当我解雇Y_ViewController时可以更改A_NavigationController的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.
答案 0 :(得分:0)
“rootViewController”只是navigationStack底部的UIViewController。要更改它,您只需将索引0处的对象设置为您想要的任何控制器