Changing UITableView's section header/footer title without reloading the whole table view

前端 未结 10 626
轮回少年
轮回少年 2020-12-03 04:47

Is there any way to reload the section header/footer of a table view without calling [tableView reloadData];?

In fact, I want to show the number of cel

10条回答
  •  一整个雨季
    2020-12-03 05:12

    I managed to do it in an indirect way: I created a UILabel and set it as section header/footer.

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
        // update sectionFooterView.text    
        return sectionFooterView;
    }
    
    - (void)viewDidLoad {
        // create sectionFooterView in Interface Builder, change the frame here
        // use Font-size:15 , BG-Color: clearColor , text-Color: RGB=(97,105,118) 
        // and Text-alignment:Center to look like table view's original footer
        sectionFooterView.frame = CGRectMake(0, 10, 320, 12);
    }
    

    Does anyone know a way to do this without setting a custom footer view?

提交回复
热议问题