How can I pop specific View Controller in Swift

前端 未结 16 2938
一生所求
一生所求 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:53

    Swift 4 / Swift 5

     for controller in self.navigationController!.viewControllers as Array {
                if controller.isKind(of: HomeViewController.self) {
                    self.navigationController!.popToViewController(controller, animated: true)
                    break
                }
            }
    

提交回复
热议问题