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
Press Cmd+N to create a new SwiftUI View, calling it “MainView”. Creating tabs is as easy as putting different views inside an instance of TabView , but in order to add an image and text to the tab bar item of each view we need to use the tabItem() modifier.
In the ViewDidLoad include a loadData() function to prepare the data. This is executed in the initial run. When you want to reload, call loadData() again to get the data from model. In a tableView call reloadData() or in a regular view setNeedsDisplay().
Use setViewControllers(_:animated:)
myTabBarController.setViewControllers(myViewControllers, animated: true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With