Is there a way to check if MyViewController
is in the window hierarchy ?
I want to know if I can present an UIAlertController
from it :
var alert = UIAlertController(title: "Hello", message: "Just for fun", preferredStyle: UIAlertControllerStyle.Alert)
MyViewController.presentViewController(alert, animated: true, completion: nil)
The view controller's view
will have its window
property set if its in the hierarchy
if MyViewController.view.window != nil {
// In the window hierarchy
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With