How can I pop specific View Controller in Swift

前端 未结 16 2981
一生所求
一生所求 2020-12-08 02:21

I used the Objective-C code below to pop a specific ViewController.

for (UIViewController *controller in self.navigationController.         


        
16条回答
  •  没有蜡笔的小新
    2020-12-08 02:43

    Please use this below code for Swift 3.0:

     let viewControllers: [UIViewController] = self.navigationController!.viewControllers as [UIViewController];
    
    for aViewController:UIViewController in viewControllers {
                if aViewController.isKind(of: YourViewController.self) {
                    _ = self.navigationController?.popToViewController(aViewController, animated: true)
                }
            }
    

提交回复
热议问题