ios - Swift - 远程通知和导航 Controller 流程

标签 ios swift uinavigationcontroller push-notification

我正在设置推送通知,我将用一些数据发送到设备,我想在导航 Controller 堆栈上加载某个 View 。 但是,我想保持导航堆栈完好无损,即目标 View Controller 应该仍然有一个带后退按钮的导航栏,可以返回到上一个 View Controller 等。

流程: 导航 Controller -> Root View Controller -> 目标 Controller 。

如何在 UINavigationController 堆栈中显示特定的非 Root View Controller 而不丢失层次结构和功能?

现在我正在这样做,它正确显示了 View Controller ,但没有导航栏:

        let idPushNotification = userInfo["idPushNotification"] as String
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let destinationViewController = storyboard.instantiateViewControllerWithIdentifier("DestinationViewController") as DestinationViewController
        destinationViewController.idPushNotification = idPushNotification.toInt()!

        let navigationController = self.window?.destinationViewController;
        navigationController?.presentViewController(destinationViewController, animated: false, completion: nil)

最佳答案

您正在呈现 View Controller ,因此它不会显示任何导航栏。您需要在导航堆栈上使用 pushViewController

    let navigationController:UINavigationController = self.window?.destinationViewController as UINavigationController;
    navigationController?.pushViewController(destinationViewController, animated: false)

关于ios - Swift - 远程通知和导航 Controller 流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27415452/

相关文章:

ios - 在导航 Controller 中推送 Controller 时如何隐藏父标签栏

ios - 在 UINavigationController 中更改提示的字体

iphone - NavigationController 和模态视图

ios - 应用程序开头的介绍

ios - 在UNNotificationService扩展程序的Push Notification Payload中修改 'sound'属性

ios - Xcode map 套件 : How to trigger event upon specific location enter

swift - 加载嵌套数据的效率

ios - 如何使用回调在 Swift 中进行异步调用,以便主 UI 不会挂起?

iphone - 如何使用自定义中心按钮在 uiTabBarController 中选择选项卡

ios - 将多个图像作为 PFFiles 添加到解析数组