3D Touch 不工作
3D Touch not working
我正在尝试将 3dtouch 项目添加到我的应用程序图标。这是我的代码:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "com.eDidaar.eDidaar.addEvent"{
let sb = UIStoryboard(name: "Main", bundle: nil)
let addEventVC = sb.instantiateViewController(withIdentifier: "addEvent") as! ADDEvent
if let navigationController = window?.rootViewController as? UINavigationController {
navigationController.pushViewController(addEventVC, animated: true)
}
}
但是当我启动应用程序时 3d touch 没有出现
我做错了什么
我将我的代码更改为这个,它工作正常:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "com.eDidaar.addEvent" {
let sb = UIStoryboard (name: "Main", bundle: nil)
let addEventVC = sb.instantiateViewController(withIdentifier: "addEvent")
let root = UIApplication.shared.keyWindow?.rootViewController
root?.present(addEventVC, animated: false, completion: { () -> Void in
completionHandler(true)
})
}
}
我正在尝试将 3dtouch 项目添加到我的应用程序图标。这是我的代码:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "com.eDidaar.eDidaar.addEvent"{
let sb = UIStoryboard(name: "Main", bundle: nil)
let addEventVC = sb.instantiateViewController(withIdentifier: "addEvent") as! ADDEvent
if let navigationController = window?.rootViewController as? UINavigationController {
navigationController.pushViewController(addEventVC, animated: true)
}
}
但是当我启动应用程序时 3d touch 没有出现 我做错了什么
我将我的代码更改为这个,它工作正常:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "com.eDidaar.addEvent" {
let sb = UIStoryboard (name: "Main", bundle: nil)
let addEventVC = sb.instantiateViewController(withIdentifier: "addEvent")
let root = UIApplication.shared.keyWindow?.rootViewController
root?.present(addEventVC, animated: false, completion: { () -> Void in
completionHandler(true)
})
}
}