我正在尝试向我的应用添加快捷方式项。我正在显示该项目,并且正在响应,但无法确定如何使Segue正常工作。我将其转到右侧的选项卡,但需要转到根视图并从那里执行segue。
segue已经在ProjectList视图控制器上设置,其名称为“ 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
}
}
答案 0 :(得分:0)
解决了
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
}
}