3D Touch快速操作始终使用相同的控制器?

时间:2017-07-30 14:11:49

标签: ios iphone swift 3dtouch quickaction

相对较新的Swift,如果这很明显,那就很抱歉。尝试创建快速操作链接以打开不同的选项卡视图:

Quick Action Links

我尝试使用此代码打开动作虽然它总是进入第一个快速动作'精选'??

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

0 个答案:

没有答案