3D Touch快捷方式-尝试加载表格视图控制器,但如果通过3D touch打开,则只会显示为空的表格视图

时间:2018-08-16 03:42:16

标签: ios swift

我想要一个3D touch快捷方式打开一个用列表填充的tableviewcontroller,但是它只打开一个空的tableview。这是我的代码:

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
    //Mark: Called when user tries 3D Touch

    if shortcutItem.type == "com.myname.myApp.gotoTableView"
    {
        let sb = UIStoryboard(name: "Main", bundle: nil)
        let listVC = sb.instantiateViewController(withIdentifier: "ListView") as! TableViewController

        let root = UIApplication.shared.keyWindow?.rootViewController

        root?.present(listVC, animated: false, completion: { () -> Void in completionHandler(true)
        })
    }
}

还有我的info.plist

UIApplicationShortcutItemIconFile - readlistshortcut
UIApplicationShortcutItemTitle - List
UIApplicationShortcutItemType - com.myname.myApp.gotoTableView

我想念什么吗?

0 个答案:

没有答案