tableView会遇到这种情况,存在多余的cell:
解决方式为:添加一个tableFooterView(ps:注意这里必须要设置UIView大小不然背景色添加不上去)
tableView.tableFooterView = [[UIView alloc]initWithFrame:SCREEN_FRAME];
tableView.tableFooterView.backgroundColor = MainBackGroundColor;
不过添加后最底下会存在一条分割线,去除方法为:在-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
中判断是否为最后一个cell,然后设置cell.separatorInset = UIEdgeInsetsMake(0, 0, 0,
[UIScreen mainScreen].bounds.size.width
);
最后效果如下: