做開發(fā)時(shí)题画,我們通常會(huì)從一個(gè)頁面push到另一個(gè)頁面,然后在其中會(huì)有無數(shù)的push沽翔,但是返回上一級(jí)的時(shí)候逝她,我們都需要返回的是最初的頁面浇坐,這時(shí)候會(huì)有兩種做法:
1 推出到根視圖控制器
[self.navigationController popToRootViewControllerAnimated:YES];
這種情況適用于你原本的頁面就是跟視圖控制器的情況
2 推出到指定的視圖控制器
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[AViewController class]]) {
AViewController *A =(AViewController *)controller;
[self.navigationController popToViewController:A animated:YES];
}
}
這里的AViewController就是你push之前的頁面。