【问题标题】:'AppDelegate' does not have member named 'navController'“AppDelegate”没有名为“navController”的成员
【发布时间】:2015-06-05 02:42:34
【问题描述】:

我正在尝试访问我的 AppDelegate.swift 文件中的 self.navController 对象,以处理接收来自 Parse 的推送通知。我正在关注 Parse 文档here (Responding to the Payload)。代码示例的最后一行以 self.navController ... 开头,但是当我尝试在我的 AppDelegate.swift 文件中编写它时,我收到错误消息“AppDelegate 没有名为 navController 的成员。”我的搜索表明这应该是我的 AppDelegate 的一个字段。有人可以解释为什么它没有被识别吗?

为什么我需要导航控制器:

我正在开发一个消息应用程序,并希望在用户单击显示另一个用户向他们发送消息的通知横幅时打开我的消息视图控制器。

【问题讨论】:

    标签: ios swift parse-platform apple-push-notifications appdelegate


    【解决方案1】:

    请在didFinishLaunchingWithOptions中使用以下代码

    let navController = application.windows[0].rootViewController as UINavigationController
    

    【讨论】:

    • 谢谢,虽然这并不能解决我的根本问题。我想这是一个单独的问题..
    • 从技术上讲,您的答案不正确,因为 window 不是数组。我最终使用了这个代码self.window?.rootViewController?.navigationController?.pushViewController(convoVC, animated: true)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 2014-11-09
    • 2015-06-09
    • 1970-01-01
    相关资源
    最近更新 更多