I am attempting to present a tableViewController embedded in a NavigationController on top of a ViewController embedded in a NavigationController.
I keep getting the error: that the view controller cannot be presented because it is not in the window hierarchy.
In short, I'm trying to allow a user to click on the number of likes
on a post and then be directed to an embedded TableViewController in NavigationController and it's not working.
For some reason it works when being presented from a tab bar controller when I try clicking on the like number but not when I do it from a navigation controller. The code for the action of clicking the like number is as follows and is located in a collection view cell swift file:
@IBAction func LikeNumber_tapped(_ sender: Any) {
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LikedByVC2") as? UINavigationController
let tableVC = vc?.viewControllers.first as! LikedByTableViewController
tableVC.postKey = self.postKey
self.window?.rootViewController?.present(vc!, animated: true, completion: nil)
}
Is it possible to do what I am attempting? I tried to make the question as simple as possible but let me know if I need to elaborate more. Thanks in advance.