Reputation: 305
So I have just added 3d shortcuts to my app. Now they open the correct ViewController
but I can't navigate through the rest of the app. It appears to open the ViewController
as a modal
. How to I get the navigation bar to show as well?
Here is the code is 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)
})
}
}
Upvotes: 1
Views: 479
Reputation: 302
Another way to handle the presentation of the VC is to embed your VC in a Navigation Controller. You would then give the NavigationController a Storyboard ID. Then you would present it to the screen. Here is an example:
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)
})
The "CharacterLog" would be set as the NavigationController StoryBoard ID instead of the ViewController you as shown in the link below.
https://www.screencast.com/t/mcG5v5gvz
I'm going to post it in the answer as well, But here is the link to the Github tutorial I made for you to follow.
https://github.com/karpisdiem/3D-Quick-Qctions-Swift
Upvotes: 1
Reputation: 875
Try to load the navigationController directly from the storyboard.
let charLog = sb.instantiateViewController(withIdentifier: "NavCharacterLog") as! UINavigationController
Upvotes: 0