2017-04-02 65 views
0

嘿傢伙,所以我的3D​​觸摸快捷鍵,我把我的info.plist顯示出來,但是當我選擇它們時,只有在我的代碼中首先出現的那一個把我帶到視圖控制器。其他人不工作(帶我看我說的)。三維觸摸靜態快捷方式

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { 
    if shortcutItem.type == "com.amansk.software" { 
     self.window = UIWindow(frame: UIScreen.main.bounds) 
     let storyboard = UIStoryboard(name: "Main", bundle: nil) 
     let initialViewController = storyboard.instantiateViewController(withIdentifier: "sw") 
     self.window?.rootViewController = initialViewController 
     self.window?.makeKeyAndVisible() 

     if shortcutItem.type == "com.amansk.hardware" { 
      self.window = UIWindow(frame: UIScreen.main.bounds) 
      let storyboard = UIStoryboard(name: "Main", bundle: nil) 
      let initialViewController = storyboard.instantiateViewController(withIdentifier: "hw") 
      self.window?.rootViewController = initialViewController 
      self.window?.makeKeyAndVisible() 
     } 
    } 
} 

回答

1

第二if語句應該是第一個

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { 
    if shortcutItem.type == "com.amansk.software" { 
     self.window = UIWindow(frame: UIScreen.main.bounds) 
     let storyboard = UIStoryboard(name: "Main", bundle: nil) 
     let initialViewController = storyboard.instantiateViewController(withIdentifier: "sw") 
     self.window?.rootViewController = initialViewController 
     self.window?.makeKeyAndVisible() 
    } else if shortcutItem.type == "com.amansk.hardware" { 
     self.window = UIWindow(frame: UIScreen.main.bounds) 
     let storyboard = UIStoryboard(name: "Main", bundle: nil) 
     let initialViewController = storyboard.instantiateViewController(withIdentifier: "hw") 
     self.window?.rootViewController = initialViewController 
     self.window?.makeKeyAndVisible() 
    } 

}

OUTSIDE