I want to presentViewController when an alertController is presented.
I want such as if user presses the Ok button now i want to show the ViewController from AppDelegate on PushNotification.
I came to know on SO that UIAlertController is presented on different thread so want to present the ViewController after user presses Ok Button and moves on to main thread as below:
func presentRScreenFromRootViewController()
{
let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let rViewController = storyboard.instantiateViewControllerWithIdentifier("rsh") as! R_SVC
dispatch_async(dispatch_get_main_queue(),{
self.window?.rootViewController?.presentViewController(rViewController, animated: true, completion: nil)
});
}
But I get warning as:
Attempt to present <BB.R_SVC: 0x15b983600> on <SWRevealViewController: 0x15652df00> which is already presenting <UIAlertController: 0x15b4f2dd0>
This is because the viewcontroller is presenting alertcontroller.Other times its working well..My rootViewController changes and moves to next screen..But when there is UIAlertController i get warning as attempt to present viewcontroller which is not in the view hierarchy
What am i doing wrong?