我使用Objective-C下面的代码弹出特定的代码ViewController。
Objective-C
ViewController
for (UIViewController *controller in self.navigationController.viewControllers) { if ([controller isKindOfClass:[AnOldViewController class]]) { //Do not forget to import AnOldViewController.h [self.navigationController popToViewController:controller animated:YES]; break; } }
我该如何在Swift中做到这一点?
尝试以下代码:
for controller in self.navigationController!.viewControllers as Array { if controller.isKind(of: ViewController.self) { self.navigationController!.popToViewController(controller, animated: true) break } }