Search code examples
iosuiviewuitabbarcontroller

iOS - Reload UIView when tab icon clicked?


I have an application that uses a UITabBarController, and inside each tab I have Navigation Controllers.
I would like to make one of the views reload itself after an action happens in another view, so that when the user goes back to that view - it's updated.
Is it possible?


Solution

  • The simplest way to accomplish this is to put your loading code into viewWillAppear: instead of viewDidLoad. While viewDidLoad may only get called once, when your view is initialized, viewWillAppear: is called any time your view controller is about to be presented, whether it be in the tab bar, in a navigation controller, etc., which gives you a nice hook to implement loading and layout functionality.