【问题标题】:Swift - Remote Notifications and Navigation Controller FlowSwift - 远程通知和导航控制器流程
【发布时间】:2014-12-11 04:38:05
【问题描述】:

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

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

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

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

        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)

【问题讨论】:

标签: ios swift uinavigationcontroller push-notification


【解决方案1】:

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

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

【讨论】:

  • 是的,我在发布问题后不久尝试过,这就是解决方法。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-19
  • 2014-10-11
  • 2020-05-27
相关资源
最近更新 更多