how to hide empty rows in a UITableView and change the height of the Uitableview based on non-empty rows

前端 未结 11 1984
离开以前
离开以前 2021-01-30 05:06

I have couple of problems with my UITableView.

  1. When I add a UITableview on my page, by default it brings up some fixed number of rows,

11条回答
  •  轮回少年
    2021-01-30 05:31

    If your tableview has multiple sections, you may try using this:

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
        if (section == tableView.numberOfSections - 1) {
            return [UIView new];
        }
        return nil;
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
        if (section == tableView.numberOfSections - 1) {
            return 1;
        }
        return 0;
    }
    

提交回复
热议问题