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

前端 未结 11 1879
离开以前
离开以前 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:25

    I solved the problem by creating a simple UIView as footer view with the same background color as the table background:

    (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
        UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease];
        view.backgroundColor = [UIColor whiteColor];
        return view;
    }
    

    Maybe you have to disable scrolling in your table view in addition.

提交回复
热议问题