I am trying to add 3D Touch Quick Actions from the home screen and I am using the following code:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabVC = storyboard.instantiateViewController(withIdentifier: "TabVC") as! UITabBarController
let mainVC = storyboard.instantiateViewController(withIdentifier: "NavMoreVC") as! UINavigationController
let foodVC = storyboard.instantiateViewController(withIdentifier: "FoodVC") as! FoodTableViewController
window?.rootViewController = tabVC
self.window?.makeKeyAndVisible()
mainVC.pushViewController(foodVC, animated: true)
I'm trying to navigate to the Find Food view controller after the user tapped on the shortcut, but the code above gives me an error in the console:
Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x10e022600>.
Is there a way for the app to push to the Find Food view controller while maintaining the Tab Bar and Navigation Controllers. Thanks!!
Did some more digging and found the solution to it. I used the following code in the AppDelegate:
let myTabBar = self.window?.rootViewController as? UITabBarController
myTabBar?.selectedIndex = 0
let nvc = myTabBar?.selectedViewController as? UINavigationController
let vc = nvc?.viewControllers.first as? MoreViewController
nvc?.popToRootViewController(animated: false)
return vc!.openPageFor(shortcutIdentifier: shortcutIdentifier)
Then inside my MoreViewController I had a function that will call the different segues based on the shortcutIdentifier.