【发布时间】:2009-12-14 05:27:20
【问题描述】:
这是交易:我有一个包含 2 个部分的 UITableView,我想在第一部分为空时显示一个“无数据”单元格,这样 2 个部分的标题就不会粘在一起(因为它看起来很奇怪) .
它工作得很好(尽管我一开始很难让它工作,see this thread)。我正在使用 viewForFooterInSection :
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if(section == 0)
{
if([firstSectionArray count] == 0)
return 40;
else
return 0;
}
return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
if(section == 0)
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(200, 10, 50, 44)];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor colorWithWhite:0.6 alpha:1.0];
label.textAlignment = UITextAlignmentCenter;
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
label.text = @"No row";
return [label autorelease];
}
return nil;
}
但是当我显示部分页脚视图时,背景颜色变成纯白色。见图片:
alt text http://img683.yfrog.com/img683/9480/uitableviewproblem.png
当背景充满空单元格时,我更喜欢它。有谁知道该怎么做?谢谢
【问题讨论】:
标签: iphone uitableview