我想要一个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
我想念什么吗?