ios - Swift Deeplink 到已经打开的应用程序已经打开的 View Controller ?

标签 ios swift deeplink

我有一个接受深层链接 URL 并使用链接中的变量打开 View Controller 的应用程序,如果用户使用深层链接首次打开/运行该应用程序,它会运行良好。

但是,如果应用程序已经打开/或在后台并且打开了该 View Controller ...然后它会再次打开相同的 View Controller ,这样我就有了两个。我不想再打开 View Controller 。

有什么方法可以识别已经打开的 View Controller 并将变量从深层链接传递给它吗?

或者我需要以某种方式关闭它然后重新打开它吗?

我愿意接受建议....提前致谢。

最佳答案

尝试使用 UIApplication.shared.keyWindow?.rootViewController 并测试它是什么类。例如:

if let vc = UIApplication.shared.keyWindow?.rootViewController {
    if vc is SomeViewController {
        // Do something.
    }
}

关于ios - Swift Deeplink 到已经打开的应用程序已经打开的 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49019444/

相关文章:

android - 如何在应用程序中创建深层链接?

ios - MFMailComposeViewController canSendMail 返回 YES 但不在 iOS 中发送邮件

swift - 滚动 TableView 时,我需要在 TableView 最顶部传递的行

ios - 如何从我的应用程序打开其他应用程序

swift - 我想通过单击 UISegmented Control 来切换 UIView 但我的代码无法正常工作

ios - Swift:ScrollView不滚动(如何设置约束)?

ios - 谷歌应用索引 ios 搜索结果

ios - Facebook iOS SDK 不工作

ios - 将 MKMap 分解为图 block ——图 block 太小

objective-c - NSLog,如何为不同大小的字段生成固定宽度的输出?