When tap a button, app user can switch between two roles, user and manager.
In my tabBarViewController
's viewDidLoad
method,
if userRole == "manager" {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let managerHomeViewController = (mainStoryboard.instantiateViewController(withIdentifier: "ManagerHome")) as! UINavigationController
let managerProfileViewController = (mainStoryboard.instantiateViewController(withIdentifier: "ManagerProfile")) as! UINavigationController
self.viewControllers?.replaceSubrange(0...1, with: [managerHomeViewController,managerProfileViewController])
}
to change first two tab bar items when loading the view.
In anotherViewController
where user tap a button to change role,
MainTabBarViewController().aboveFunction()
After running this line, the tab bar items are not updated. It can only be updated to new tab bar items by force closing the app and relaunch it. How to reload tab bar items instantly after updating them?