5

I have a headerView in my UITableView which a bunch of stats in, I set it like this in the viewDidLoad method:

self.tableView.tableHeaderView = [self headerView];

The headerView method, just returning my view. However, the stats only update when the is loaded, if I go to a child view from this one and return the stats don't update, so how can I reload this view when returning to it from a child view controller? Instead of just when the view loads?

Let me simplify this:

How can I reload the tableHeaderView upon returning to the view from a child view controller? So I press back to return to my view with the header and I need to reload it at this point.

Thanks.

Josh Kahane
  • 16,765
  • 45
  • 140
  • 253

1 Answers1

2

The header view is not automatically reloaded when you reload the UITableView. You have to manage this view yourself. If you want to update it before your view controller appears:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    MyHeaderView *v = (MyHeaderView *)[[self tableView] tableHeaderView];
    [v updateWithData:[self someData]];
}
Sebastian Celis
  • 12,185
  • 6
  • 36
  • 44