美文网首页
NavigationController 任意pop

NavigationController 任意pop

作者: 秀才不才 | 来源:发表于2017-12-13 16:45 被阅读58次

A-(push)-B-(push)-C,C-(pop)-D-(pop)-A

NSMutableArray *vcArrs = [self.navigationController.viewControllers mutableCopy];
index = 1;
[viewControllers replaceObjectAtIndex:index withObject:B];
[self.navigationController setViewControllers: vcArrs];

A-(push)-B-(push)-C-(push)-D,D-(pop)-B

C的代码
index = 1;
[vcArrs removeObjectsInRange:NSMakeRange(index+1, viewControllers.count-index-2)];
[self.navigationController setViewControllers: vcArrs];

以此类推
就这样吧……

相关文章

网友评论

      本文标题:NavigationController 任意pop

      本文链接:https://www.haomeiwen.com/subject/vfhzixtx.html