Reloading tableView header in ios7

后端 未结 2 1205
野趣味
野趣味 2021-01-04 14:10

How can I do it without reloading all table?

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    UIView *header;

         


        
2条回答
  •  滥情空心
    2021-01-04 14:55

    You need to use -reloadSections:withRowAnimation:

    So when you need to update your headers:

    NSIndexSet *headers = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [self.tableView numberOfSections])];
    [self.tableView reloadSections:headers withRowAnimation:UITableViewRowAnimationAutomatic];
    

    If you've only got one section (as you just mentioned in your updated question) you can just call

    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
    

提交回复
热议问题