Swift - 远程通知和导航控制器流程 [英] Swift - Remote Notifications and Navigation Controller Flow

查看:58
本文介绍了Swift - 远程通知和导航控制器流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am setting up Push Notifications that I will send to the device with some data, and I want to load a certain view on the navigation controller stack. However, I want to keep the navigation stack intact, i.e. the destination view controller should still have a navigation bar with back button to go backwards to previous view controller, etc.

流程:导航控制器 -> 根视图控制器 -> 目标控制器.

Flow: Navigation Controller -> Root View Controller -> Destination Controller.

如何在不丢失层次结构和功能的情况下在 UINavigationController 堆栈中显示特定的非根视图控制器?

How can I go about displaying a specific, non-root, view controller in a UINavigationController stack without losing hierarchy and functionality?

现在我正在这样做,它正确显示了视图控制器,但没有导航栏:

Right now I am doing this and it shows the View Controller properly, but no navigation bar:

        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)

推荐答案

您正在呈现视图控制器,因此它不会显示任何导航栏.导航堆栈上需要 pushViewController

You are presenting the view controller so it will not show any navigationBar.You need pushViewController on navigation stack

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

这篇关于Swift - 远程通知和导航控制器流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆