2
votes

Is there a way to unload a UITabBarController when it is popped off the stack of a UINavigationController, so that it is reloaded fresh when pushed back on the stack? I need to clear all of the data in all of the view controllers in the tab bar.

I've tried various methods of iterating through the tab bar's view controllers and setting each to nil, and setting the tab bar's view to nil, and I've also tried sending the didReceiveMemoryWarning message to each of the views.

In my main nib file (MainWindow.xib), I have a UINavigationController and a UITabBarController. Both are wired up to the app delegate as IBOutlets to ease in automatically loading the controllers, especially the tab bar controller.

The nav controller first loads another view as its root view, and when the user taps a button, the UITabBarController is pushed onto the UINavigationController stack.

This all works fine.

Now I want to be able to pop the UITabBarController off the nav controller stack, so the root view of the nav controller is redisplayed, and have it reset all of the data on all the views in the UITabBarController while it is hidden (off the stack).

From one of the view controllers in the tab bar controller, I can call [self.tabBarController.navigationController popToRootViewController:YES] and that works fine.

But how do I unload and reload all of the UITabBarController's views?

1

1 Answers

1
votes

You should be able to re-init the view controllers and pass them into your tabBarController's setViewControllers: method.