2017-04-02 14 views
0

어이 얘들 아 내 내 터치 터치 지름길을 내 info.plist에 표시하면 표시되지만 내가 선택한 경우에만 내 코드에서 첫 번째로 표시되는 뷰 컨트롤러로 이동합니다. 다른 사람들은 작동하지 않습니다. (제가 언급 한 견해로 나를 데려가십시오.)3D 터치 정적 바로 가기

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

가 처음

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

외부 되어야 하는지를