【问题标题】:Open controller from app delegate从应用委托打开控制器
【发布时间】:2016-12-28 17:43:22
【问题描述】:

如果使用下面的代码单击推送通知,我正在尝试从应用程序委托打开视图控制器

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
       }

}

控制器打开,但显示导航的菜单图标不起作用。我怎样才能让菜单图标显示侧面导航。

【问题讨论】:

  • 究竟是什么不在这里工作?可以附上图片吗?
  • @Honey 代码工作正常,但使用该代码控制器中的菜单图标在打开时不起作用
  • 你用什么库做菜单?

标签: ios swift swift2


【解决方案1】:

试试这个

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

【讨论】:

    猜你喜欢
    • 2020-09-20
    • 2015-08-16
    • 2013-10-29
    • 2013-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2023-03-20
    相关资源
    最近更新 更多