相对较新的Swift,如果这很明显,那就很抱歉。尝试创建快速操作链接以打开不同的选项卡视图:
我尝试使用此代码打开动作虽然它总是进入第一个快速动作'精选'??
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "matthewfrankland.RonaldYule.contacts"{
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "contacts") as! Contact
window?.rootViewController?.addChildViewController(vc)
}
if shortcutItem.type == "matthewfrankland.RonaldYule.allvideos" {
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "allVideos") as! AllVideos
window?.rootViewController?.addChildViewController(vc)
}
if shortcutItem.type == "matthewfrankland.RonaldYule.featured"{
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "featured") as! Featured
window?.rootViewController?.addChildViewController(vc)
}
}