【问题标题】:How to open two specific view controller on buttons click in notification content extension?如何在通知内容扩展中单击按钮上打开两个特定的视图控制器?
【发布时间】:2019-01-08 15:38:19
【问题描述】:

我正在使用通知内容扩展。在 extensionViewController 中,有两个按钮用于不同的操作,第一个按钮移动到 firstViewController(FirstVC),第二个按钮移动到 secondViewController(SecondVC)。 我为此使用故事板 ID,然后它也显示错误(使用未声明的类型 FirstVC)。

let vc = self.storyboard?.instantiateViewController(withIdentifier: "first") as! FirstVC self.present(vc, animated: true, completion: nil)

如果有任何解决方案,请指导我。谢谢。

【问题讨论】:

  • 请附上您的代码
  • 让 vc = self.storyboard?.instantiateViewController(withIdentifier: "first") as! FirstVC self.present(vc, animated: true, completion: nil)
  • 这个FirstVC在哪里??您应该转换为您的 viewController 名称而不是 UIviewController。
  • 请再次查看我的评论。
  • 不要在 cmets 中发布代码,而是更新您的问题。

标签: ios iphone swift xcode push-notification


【解决方案1】:

由于 UINotification Content 扩展是另一个目标,因此您需要将 FirstVC 和 secondVC 添加到 UINotificationContent Extension 目标。然后你需要用名字初始化你的故事板,然后使用上面的代码。希望这能解决您的问题。

如何将文件添加到目标? 选择您的文件(例如 FirstVC),然后在身份检查器上选择文件符号,然后勾选文件的目标成员身份

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    相关资源
    最近更新 更多