简体   繁体   中英

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.

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]];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM