Reputation: 1407
I am building an iOS app. this app has this structure:
tab bar item > box-view > navigation controller > table view
tab bar item > navigation controller > view
The first table view has a downPicker (an open source drop down menu). You can initialize a downPicker with an array to give him the elements to display.
Unfortunately, my second view, has an add button where you can add an element inside this downpicker.
The problem is, that if I open the table view, switch to the view, add an element, switch back to the table view (where the downpicker is located) those values do not get updated.
This problem does not appear if I go back to box-view after adding an element.
Currently the downPicker init is inside the viewWillLoad. So, is there a way to detect this switch between tabs and actually refresh the downPicker?
Upvotes: 0
Views: 266
Reputation: 11039
Make a class that inherits from UITabBarController and override the following method:
//Swift
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
//do your job here
}
//ObjC
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
//do your job here
}
And set the class to your TabBarController from the storyboard.
Upvotes: 3