For my second item of my tab bar controller, I have a navigation controller that I want to present modally. I keep getting an error that says
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller .'
Then my app crashes and goes to the app delegate.
This is the code I have so far
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
if let restoreID = viewController.restorationIdentifier {
if restoreID == "NavigationCamera" {
if let nav = tabBarController.viewControllers![tabBarController.selectedIndex] as? UINavigationController {
print("Nav is allowed")
//let newVC = tabBarController.storyboard?.instantiateViewController(withIdentifier: "CameraView")
tabBarController.present(nav, animated: true, completion: {
print("complete")
})
return false
}
}
}
return true
}