2017-09-19 3 views
0

Ich versuche, 3dtouch Element zu meinem App-Symbol hinzuzufügen. hier ist mein Code:3D Touch funktioniert nicht

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


} 

aber 3D-Touch erscheint nicht, wenn ich die Anwendung starten was bin ich falsch

Antwort

0

tun änderte ich meinen Code zu diesem und es hat gut funktioniert:

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

}