Objective c removeFromParentViewController不更新UINavigationbar

Objective c removeFromParentViewController不更新UINavigationbar,objective-c,uikit,uinavigationbar,uinavigationcontroller,Objective C,Uikit,Uinavigationbar,Uinavigationcontroller,我想从UINavigationController中删除所有ViewController。所以我使用这个代码 for (UIViewController* controller in navigationController.viewControllers) { [controller removeFromParentViewController]; } 之后,我创建了一个新的viewController并按下它 UIViewController* newVC=[[UIViewControl

我想从UINavigationController中删除所有ViewController。所以我使用这个代码

for (UIViewController* controller in navigationController.viewControllers) {
[controller removeFromParentViewController];
}
之后,我创建了一个新的viewController并按下它

 UIViewController* newVC=[[UIViewController alloc] init]; 
 [navigationController pushViewController:newVC animated:YES];

问题是所有的viewcontrollers都会完美弹出并添加newVC,但按下newVC时,导航栏会显示一个后退按钮和newVC的标题。单击“上一步”按钮,它将动画显示为oldVC的导航栏,标题为oldVC,我已经在上面的循环中删除了该标题

removeFromParentViewController
是一种
UIViewController
方法,因此它与
UINavigationBar

对于
UINavigationController
的情况,
popViewControllerAnimated:
方法处理
removeFromParentViewController
部分以及导航栏

您可以直接更新
UINavigationController
viewControllers
的整个数组,调用`setViewControllers:animated:


请参见

[navigationController设置视图控制器:[NSArray arrayWithObject:newVC]]