How to refresh Tab Bar Items in swift ios

Zhanserik picture Zhanserik · May 30, 2017 · Viewed 13.1k times · Source

I do app like Instagram with tab bar items. In app I have simple user and company user.

I have main ViewController:

MainTabBarController: UITabBarController

with 5 tab bar items. And each item has own ViewController

I need refresh MainTabBarController when user is Simple user it is 5 items and when user is Company user it is 4 items. How to refresh or reload without close app?

One solution I already do with UserDefaults, but need close app.

Platform iOS > 9.0, Swift 3.0

Answer

Jože Ws picture Jože Ws · May 30, 2017

Use setViewControllers(_:animated:)

myTabBarController.setViewControllers(myViewControllers, animated: true)