Question: Open controller from app delegate


Open controller from app delegate

Answers 1
Added at 2016-12-28 18:12

I am trying to open a view controller from app delegate if a push notification is clicked with the code below

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
        if(application.applicationState==UIApplicationState.Inactive ){
            let sdViewController = mainStoryboardIpad.instantiateViewControllerWithIdentifier("StudentViewController") as! StudentViewController
            let navController = UINavigationController(rootViewController: sdViewController)
            navController.setViewControllers([sdViewController], animated:true)
            self.window?.rootViewController = navController


The controller opens, however the menu icon to reveal the navigation does not work. How can i make the menu icon reveal the side navigation.

Answers to

Open controller from app delegate

nr: #1 dodano: 2016-12-28 20:12

Try this

let rootViewController = self.window!.rootViewController as! UINavigationController
rootViewController.pushViewController(sdViewController, animated: true)
Source Show
◀ Wstecz