In have a UITabBarController with several UIViewControllers. Inside one of the controllers, when a certain condition is met, I want to instantiate another UIViewController which is a child of the same UITabBarController. I keep getting this error "Application tried to present modally an active controller", but I don't understand how is scheduleNavController already active. I looked up several answers on SO, but I still don't understand what is my mistake and how can I solve it? The flow of the app is like this: WelcomeViewController,LoginViewController,UITabBarController and the children of the UITabBarController.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabController = storyboard.instantiateViewController(withIdentifier: "CentralTabBarControllerID") as! UITabBarController
if let viewControllers = tabBarController?.viewControllers {
let scheduleNavController = viewControllers[1] as! UINavigationController
let scheduleVC = scheduleNavController.childViewControllers[0] as! Schedule
tabController.present(scheduleNavController, animated: true, completion: {
scheduleVC.segmentedControlIndexReceivedFromClaimDetail = self.segmentedControlIndex
})
}
scheduleNavController
from the array of active view controllers and then try and present it morally. – Paulw11selectedIndex
of your tab bar controller? – Andreas OetjenselectedIndex
? I have seen lots of questions asked using the method I tried in my original question. I think such answer would be helpful for other SO members. Thanks – bibscy