Reputation: 81
I'm opening a VC upon a reception of local notification.
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
application.applicationIconBadgeNumber = 0
let storyboard = UIStoryboard(name: "Main", bundle: nil)
var VC = storyboard.instantiateViewControllerWithIdentifier("PendingRequest") as! PendingRequestVC
let navController = UINavigationController.self(rootViewController: VC)
UIApplication.sharedApplication().keyWindow!.rootViewController = navController
}
The PendingRequestVC that appears has a programmatically Close Tab Item that can't be used with the navController that I created in the code above.
I've tried to insert the Tab Item from the Storyboard and used the Presented Segue instead but I'm still unable to close my PendingRequestVC.
How can I call PendingRequestVC with the NavController it's Embed in instead of creating a new one?
Or how can I close my PendingRequestVC with the created NavController?
Thanks in advance
Upvotes: 0
Views: 53
Reputation: 10479
Why you set the rootViewController of the keyWindow? You may need to presenting a modal view controller:
let rootViewController = UIApplication.sharedApplication().keyWindow!.rootViewController
rootViewController.presentViewController(navController, animated: false, completion: nil)
When you want to close the PendingRequestVC with the created NavController:
// PendingRequestVC
self.dismissViewControllerAnimated(true, completion: {});
Upvotes: 1