I am relatively new to Swift
Trying to use peek and pop previewActionItems "edit" to open the SpeciesDetailViewController in edit mode. Had an issue trying to get the segue to present the SpeciesDetailViewController and was getting an error message "Warning: Attempt to present SpeciesDetailViewController whose view is not in the window hierarchy"
. I implemented Jacob Davis' solution on found here.
This fixed the window hierarchy error, however when the SpeciesDetailViewController controller is called, both the navigation controller and tabBarController are NOT displaying.
While I believe this is caused by the SpeciesDetailViewController being called as top viewController, I am at a loss on how to fix this.
Can you please help me display both the navigation controller and tabBarController?
Below are my current codes:
Main View Controller
func showDetailsViewController() {
let topVC = topMostController()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "SpeciesDetailViewController") as! SpeciesDetailViewController
topVC.present(vc, animated: true, completion: nil)
}
func topMostController() -> UIViewController {
var topController: UIViewController = UIApplication.shared.keyWindow!.rootViewController!
while (topController.presentedViewController != nil) {
topController = topController.presentedViewController!
}
return topController
}