当A push 到 B,再push到 C,想从C pop 回A,有两种方法
1、pop到根视图控制器,没什么特别的
- (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated;
2、pop到指定控制器
- (nullable NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
然而当我们直接用第二种方法时系统会“崩溃”,原因:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.'
压入栈了,在栈内查找