我用代码来做:
NSArray *viewControllersFromStack = [self.navigationController viewControllers];
NSMutableArray *viewControllersFromStackMutable = [NSMutableArray arrayWithArray:viewControllersFromStack];
NSMutableArray *viewControllersToRemove = [[NSMutableArray alloc]init];
for (UIViewController *currentVC in viewControllersFromStack)
{
if ([currentVC isKindOfClass:[TalksViewController class]])
{
[viewControllersToRemove addObject:currentVC];
if (viewControllersToRemove.count == 2)
{
UIViewController *oneVCtoRemove = [viewControllersToRemove objectAtIndex:0];
[viewControllersFromStackMutable removeObjectneVCtoRemove];
[self.navigationController setViewControllers:viewControllersFromStackMutable];
}
}
}
问题是我在导航项中引用了已删除的 VC。如何解决?
Best Answer-推荐答案 strong>
当您想从导航堆栈中删除 View 时,您只需在导航栏上调用此方法即可将 View 从堆栈中弹出:
[self.navigationController popViewControllerAnimated:YES];
要弹出外部 View ,请使用
for(UIViewController *currentVC in viewControllersFromStack)
{
if([currentVC isKindOfClass:[TalksViewController class]])
{
[currentVC.navigationController popViewControllerAnimated:YES];
}
}
关于ios - 从导航堆栈中删除 ViewController,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/22649524/
|