1

在 iOS 5 上

我有一个 UITableViewController 设置为静态单元格。我只需要 3 行,每行都将填充内容。所以我放了3个UITableViewCell。一切正常,但是当我运行应用程序时,它总是显示超过 3 行。其余行是空行。我怎样才能只显示我打算显示的 3 行。

我应该使用分组样式并自定义外观吗?

4

2 回答 2

7

将 footerView 设置为空视图。

self.tableView.tableFooterView = [UIView new].

这适用于动态单元格。也应该在静态单元格上工作。

于 2012-04-08T08:17:10.977 回答
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,你不需要再为我渲染分隔线了,这样看起来空单元格就不会显示了(实际上,空单元格也不能被选中)

于 2013-07-31T09:50:24.257 回答