1. 程式人生 > >iOS 如何讓self.navigationController退出到指定頁面,或者讓它一次性pop出兩個頁面popViewControllerAnimated沒有

iOS 如何讓self.navigationController退出到指定頁面,或者讓它一次性pop出兩個頁面popViewControllerAnimated沒有

HomeViewController:為你想要跳轉的介面
HomeViewController *homeVC = [[HomeViewController alloc] init];

UIViewController *target = nil;

for (UIViewController * controller in self.navigationController.viewControllers) { //遍歷

 if ([controller isKindOfClass:[homeVC class]]) { //這裡判斷是否為你想要跳轉的頁面

      target = controller;

    }

 }

 if (target) {

  [self.navigationController popToViewController:target animated:YES]; //跳轉  

 }

君凱商聯網-iOS-字唐名僧