I have UITabBarControllerfour tabs. In each of the view controllers presented when the tab was selected, I have a reset button. When the button is pressed, the appearance of all view controllers will change. In particular, it will change the text of some labels in different view managers.
Is there a recommended way to update all view controllers at the same time UITabBarControllerto force them to reload their views?
My current approach is to make these view controllers conform to the protocol
@protocol XYReloadableViewController
- (void)reloadContents;
@end
and then send a message -reloadContentsto all view controllers when the button is pressed:
- (IBAction)touchUpInsideResetButton {
NSArray *viewControllers = self.tabBarController.viewControllers;
for (UIViewController<XYReloadableViewController> *viewController in viewControllers) {
[viewController reloadContents];
}
}
Then, in each of the view controllers, I would have to implement this method:
- (void)reloadContents {
[self.tableView reloadData];
}
. , ?
: , UINavigationController ? ...