gpt4 book ai didi

ios - 3D Touch 静态快捷键

转载 作者:行者123 更新时间:2023-11-29 00:25:19 25 4
gpt4 key购买 nike

嘿伙计们,我放入 info.plist 的 3D 触摸快捷方式出现了,但是当我选择它们时,只有代码中第一个出现的快捷方式将我带到指定的 View Controller 。其他人就是行不通(带我到我所说的观点)。

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

最佳答案

第二个if语句应该位于第一个OUTSIDE

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

关于ios - 3D Touch 静态快捷键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43173224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com