2012-03-20 104 views
0

在IOS 5 我有一个UITableViewController设置为静态单元格。我只需要3行将填充每行的内容。所以我把3 UITableViewCell。所有工作正常,但是当我运行应用程序时,它总是显示超过3行。其余的行是空行。我怎样才能显示我想要显示的3行。UITableView静态单元格如何限制行显示

我应该使用分组风格和自定义外观吗?

谢谢

回答

7

将footerView设置为空视图。

self.tableView.tableFooterView = [UIView new]. 

这对动态单元格有效。也应该在静态单元上工作。

+0

它也适用于静态单元格。 – DrBug 2013-10-21 20:10:17

0

实现你的UITableViewController这两种方法:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section 
{ 
    if (section == tableView.numberOfSections - 1) { 
     return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)]; 
    } 
    return nil; 
} 


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
{ 
    if (section == tableView.numberOfSections - 1) { 
     return 1; 
    } 
    return 0; 
} 

事实上,这些代码告诉tableview中,你不需要渲染分隔符行我了,所以它看起来赢得了空单元格将不显示(实际上,空单元格也不能被选中)

相关问题