有A到B再到C,我現(xiàn)在再C頁面返回的時候我想直接跳轉(zhuǎn)到A頁面 :
1.A push B push C,C pop A;

push.png
對于push比較好的一點(diǎn),就是有個棧頂控制器navigationController,它裝載所有下面的控制器,從viewControllers里面取出A,連續(xù)pop2次就可以回到A控制器:
NSArray * viewControllers = weakSelf.navigationController.viewControllers;
for (UIViewController * avc in viewControllers) {
if ([avc isKindOfClass:[UIViewAControllerA class]]) {
[self.navigationController popToViewController:(UIViewController*)avc animated:YES];
}
}
- A present B present C,C dismiss A

present.png
最簡單的方式直接使用通知,在C中dismiss的時候發(fā)出通知,在B中監(jiān)聽C然后dismiss到A:
// 在C中關(guān)掉自己
[self dismissViewControllerAnimated:YES completion:^(){
//關(guān)掉注冊controller
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_CLOSE_B object:nil userInfo:nil];
}];
// 在B中添加監(jiān)視通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(close) name:NOTIFICATION_CLOSE_B object:nil];
-(void) close{
[self dismissViewControllerAnimated:YES completion:nil];
}
// 移除通知
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}