Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reload UITableView Header View?

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.

like image 717
Josh Kahane Avatar asked Nov 04 '22 18:11

Josh Kahane


1 Answers

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]];
}
like image 62
Sebastian Celis Avatar answered Nov 09 '22 16:11

Sebastian Celis