在iOS 5上
我将一个UITableViewController设置为静态单元格。我只需要3行,这将与每一行的内容填充。所以我放了3个UITableViewCell。一切正常,但当我运行应用程序时,它总是显示超过3行。其余的行是空行。我怎么能只显示我想要显示的3行呢?
我应该使用分组样式并自定义外观吗?
发布于 2012-04-08 16:17:11
将footerView设置为空视图。
self.tableView.tableFooterView = [UIView new].
这适用于动态单元格。也应该在静态单元格上工作。
发布于 2013-07-31 17:50:24
在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,您不再需要为我呈现分隔线,这样看起来空单元格将不会被显示(实际上,空单元格也不能被选中)
https://stackoverflow.com/questions/9789290
复制相似问题