gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 22:35:55 27 4
gpt4 key购买 nike

我正在设置推送通知,我将用一些数据发送到设备,我想在导航 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com