我有一个非常简单的应用程序流。ParentVC和ChildVC.在ParentVC中,我有一个集合视图,在它的didSelectItem上,ChildVC以相对的内容打开。现在,我已经使用iOS 14 WidgetKit创建了中小型小部件,当应用程序转到后台时,存储ChildVC的PageTitle并在WidgetUI上显示。
我的要求是:当我点击Widget时,如何打开特定的ChildVC?
PS:我使用的是AppDelegate而不是SceneDelegate。
发布于 2021-07-26 11:28:37
向应用程序委托添加以下函数:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let vcNext = UIStoryboard(name: "nameYourStoryBoard", bundle: nil).instantiateViewController(withIdentifier: "IdentifierOfViewController") as! YourViewController
let tabbar = window?.rootViewController as? UITabBarController
let navcontrol = tabbar?.selectedViewController as? UINavigationController
navcontrol?.pushViewController(vcNext, animated: true)
window?.makeKeyAndVisible()
return true
}https://stackoverflow.com/questions/64928648
复制相似问题