How can I pop specific View Controller in Swift

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

    Find your view controller from navigation stack and pop to that view controller if it exists

    for vc in self.navigationController!.viewControllers {
        if let myViewCont = vc as? VCName 
        {
            self.navigationController?.popToViewController(myViewCont, animated: true)
        }
    }
    

提交回复
热议问题