ios - 从 App Delegate 打开 Controller

标签 ios swift swift2

如果使用以下代码单击推送通知,我将尝试从应用委托(delegate)打开 View Controller

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
       }

}

Controller 打开,但显示导航的菜单图标不起作用。如何让菜单图标显示侧面导航。

最佳答案

试试这个

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

关于ios - 从 App Delegate 打开 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41367114/

相关文章:

ios - 不允许加载本地资源 : blob:blobinternal:///

java - Swift 中的静态类

swift - 在初始化所有存储的属性之前使用“self”

swift - 从闭包中的函数返回

ios swift : Popup Custom view as alert box

mysql - 通过xamarin连接MySql数据库

iOS 10.0.1 和 Xcode 错误 : "Could not find developer disk image"

ios - 按下滑动删除按钮时应用程序崩溃

ios - 我无法从我的快照中获取数据以加载到我的 tableView 单元格中

swift - 使用参数集外的完成 block 实现 Swift 函数