How to scroll the header along with the UITableView?

前端 未结 6 1856
一整个雨季
一整个雨季 2021-02-02 07:07

I have a UITableView with a header. the problem I currently have is that the header doesn\'t scroll with the table. I need it to scroll off screen (above) when the

6条回答
  •  别那么骄傲
    2021-02-02 08:00

    If you write tableView.tableHeaderView = sectionHeader you will lose the actual table view header.
    If you want to have table view header along with section headers you have to set UITableViewStyle property to UITableViewStyleGrouped.
    Also if you want to calculate section header height automatically you can return UITableViewAutomaticDimension in heightForHeaderInSection method like this:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return UITableViewAutomaticDimension;
    }
    

提交回复
热议问题