How to check viewcontroller is added in stack or not

后端 未结 10 781
北恋
北恋 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:10

    Here is the code to check it.

    if let viewControllers = navigationController?.viewControllers {
        for viewController in viewControllers {
            // some process
            if viewController.isKindOfClass(ViewControllerClassName) {
                println("yes it is")
            }
        } 
    }
    

提交回复
热议问题