对 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)
}
}