这两天发现UITableView会显示多余的cell,比如说需要显示5条数据,那么应该显示5个单元格的,结果显示出来多于5个cell,多的这几个虽然没有显示出东西,但是显示出来的分割线看着是挺烦的。比如:
我发现当有页脚的时候,不会出现多余的cell,但我并不想显示页脚,经过网友提醒和自己测试,可以通过以下两种方式解决:
1,
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return0.1;//如果设为0的话,还是会显示多余的cell
}
// 页脚
-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return@"";
}
2.
//该行可以使tableView不显示多余的cell
tableView.tableFooterView = [[UIViewalloc]init];
这两种解决方式并不完美,大家若有更简便的方法,请留言告诉我!