Reputation: 1
Hey guys so my 3D touch shortcuts that I put in my info.plist show up but when I select them only the one that appears first in my code takes me to the view controller stated. The others just don't work (take me to the view I stated).
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()
}
}
}
Upvotes: 0
Views: 82
Reputation: 485
The second if statement should be OUTSIDE of the first one
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()
}
}
Upvotes: 1