How do I reload the parent UINavigationController?

My RootViewController contains a table view and a navigation bar. After the row is pressed, another view controller is pushed onto the stack, namely the SecondViewController. If I hit the back button, then the second stacked item is popped off the stack, but the parent view controller data is out of date.

How can I reload the RootViewController data? My first attempt is to implement

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

      

and call viewdidLoad again.

The problem is that on first load, viewDidLoad will be called twice.

+1


a source to share


1 answer


Load the data into the table in the viewWillAppear: method instead of the viewDidLoad. viewWillAppear will be called every time your view is displayed, whereas viewDidLoad is called only once when the view is created.



So loading data into viewWillAppear: make sure your table has the most recent data whenever it is displayed.

+9


a source







All Articles