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

前端 未结 10 640
轮回少年
轮回少年 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:09

    This should work:

        UIView.setAnimationsEnabled(false)
        tableView.beginUpdates()
    
        if let containerView = tableView.footerViewForSection(0) {
            containerView.textLabel!.text = "New footer text!"
    
            containerView.sizeToFit()
        }
    
        tableView.endUpdates()
        UIView.setAnimationsEnabled(true)
    

提交回复
热议问题