【发布时间】:2017-05-03 20:49:04
【问题描述】:
您好,我正在尝试在我的 IOS 应用程序中实现推送通知功能。目前,如果应用程序是通过推送通知打开的,我有代码将打开一个特定的视图控制器。我这样做的方式是将视图控制器推到顶部。
我现在需要做的是将一些数据从 appdelegate 传递给 viewcontroller。我知道将数据从视图控制器传递到视图控制器是使用prepareforsegue。我试过这样做,但它不起作用
我尝试研究如何完成这项任务,但很多关于 stackoverflow 的答案都是过时的 swift 代码,我无法转换为 swift 3。有人可以向我解释我如何将数据从 appdelegate 发送到视图控制器?
这里是显示在 didFinishLaunchingWithOptions 中的 VC 的代码
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController = storyboard.instantiateViewController(withIdentifier: "detailPin2") as! detailPinViewController
let navigationController = self.window?.rootViewController as! UINavigationController
navigationController.pushViewController(destinationViewController, animated: false)
【问题讨论】:
-
显示您用于显示来自 AppDelegate 的 VC 的代码。
-
已编辑帖子。代码现在应该已经启动了
-
我错过了什么吗?您在 appdelegate 的一个函数中,并且有一个指向目标 VC 的指针。你不能用你打算传递的数据调用你的 VC 的成员函数吗?
标签: ios swift3 appdelegate apn