快捷方式项目 - 执行 Segue

Shortcut Items - Perform Segue

我正在尝试将快捷方式项添加到我的应用程序。我有项目出现,它正在响应,但无法弄清楚如何让 segue 工作。我让它转到正确的选项卡,但需要转到根视图并从那里执行 segue。

已在 ProjectList 视图控制器上设置了 segue,其名称为“addProject”

我的视图故事板设置如下: UITabViewController -> UINavigationController-> UITableViewController (ProjectList) -> 其他附加视图

func applicationDidBecomeActive(_ application: UIApplication) {
    if let shortcutItem = shortcutItemToProcess {
        if shortcutItem.type == "addProject" {
            if let window = self.window, let tabBar : UITabBarController = window.rootViewController as? UITabBarController {
                tabBar.selectedIndex = 0
                
            }
        }
        shortcutItemToProcess = nil
    }
}

解决了

func applicationDidBecomeActive(_ application: UIApplication) {
    if let shortcutItem = shortcutItemToProcess {
        if shortcutItem.type == "addProject" {
            guard let window = self.window else { return }
            guard let tabBar = window.rootViewController as? UITabBarController else { return }
            guard let navCon = tabBar.viewControllers?[0] as? UINavigationController else { return }
            guard let projectList = navCon.rootViewController as? ProjectList else { return }
            
            projectList.performSegue(withIdentifier: "addProject", sender: nil)
            
            
            tabBar.selectedIndex = 0
        }
        shortcutItemToProcess = nil
    }
}