我有一个接受深层链接 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/