Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i check if another view controller is visible?

Sometimes my app crashes when two UIAlertViews are trying to be presented at the same time. How do I check if another UIAlertview is being shown before showing another one?

Here is what I tried, but it doesn't work.

Note: I'm using swift for this project.

if ViewController.isVisable == false {    
    self.presentViewController(AlertView, animated: true, completion: nil)    
}
like image 947
nachshon f Avatar asked Dec 01 '22 00:12

nachshon f


1 Answers

As a strict response to your question you could check if the ViewController's view has his window:

if ViewController.view.window != nil {

}

Anyway I encourage you to take @Wain ' s advice.

like image 127
Matteo Piombo Avatar answered Dec 10 '22 14:12

Matteo Piombo