How to check viewcontroller is added in stack or not

后端 未结 10 737
北恋
北恋 2020-12-28 08:50

I have two view controllers. I have navigated from one view to another view by press the button to using below code.

 *let secondViewController = self.storyb         


        
10条回答
  •  情话喂你
    2020-12-28 09:09

    For swift 4 you can use

     if let viewControllers = self.navigationController?.viewControllers {
           for vc in viewControllers {
                if vc.isKind(of: YourViewController.classForCoder()) {
                     print("It is in stack")
                     //Your Process
                }
           }
     }
    

提交回复
热议问题