所以我刚刚在我的应用程序中添加了 3d 快捷方式。现在他们打开了正确的 ViewController
但我无法浏览应用程序的其余部分。它似乎将 ViewController
作为 modal
打开。如何让导航栏也显示出来?
这里的代码是AppDelegate.swift
:
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "Micheal-Smith.Pathfinder-Society.charLog"
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let charLog = sb.instantiateViewController(withIdentifier: "CharacterLog") as! CharactersTableViewController
let root = UIApplication.shared.keyWindow?.rootViewController
root?.present(charLog, animated: false, completion: {
completionHandler(true)
})
}
else if shortcutItem.type == "Micheal-Smith.Pathfinder-Society.gmTools"
{
let sb = UIStoryboard(name: "Main", bundle: nil)
let charLog = sb.instantiateViewController(withIdentifier: "gmTools") as! UITabBarController
let root = UIApplication.shared.keyWindow?.rootViewController
root?.present(charLog, animated: false, completion: {
completionHandler(true)
})
}
}
最佳答案
处理 VC 显示的另一种方法是将 VC 嵌入导航 Controller 中。然后,您将为 NavigationController 提供一个 Storyboard ID。然后你会把它呈现在屏幕上。这是一个例子:
let sb = UIStoryboard(name: "Main", bundle: nil)
let charLog = sb.instantiateViewController(withIdentifier: "CharacterLog") as! UINavigationController
let root = UIApplication.shared.keyWindow?.rootViewController
root.present(charLog, animated: false, completion: {
completionHandler(true)
})
“CharacterLog”将被设置为 NavigationController StoryBoard ID 而不是 ViewController,如下面的链接所示。
https://www.screencast.com/t/mcG5v5gvz
我也会将其发布在答案中,但这是我为您制作的 Github 教程的链接。
关于ios - Xcode Swift 3d 快捷方式触摸导航栏不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41979032/