【发布时间】:2015-04-28 15:52:43
【问题描述】:
我有一个表格视图,因为我有标题标题,它们运行良好,但是标题标题值的总和变为 null,我想在我的表格视图中隐藏那个 null 标题标题。我该怎么做这个过程。请帮我编码。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [reverseOrder1 objectAtIndex:section];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 60;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 75)];
UILabel *headerTitile =[[UILabel alloc]initWithFrame:CGRectMake(20, -5, tableView.bounds.size.width-20, 75)];
headerTitile.text = [reverseOrder1 objectAtIndex:section];
headerTitile.textColor = [UIColor whiteColor];
headerTitile.TextAlignment=NSTextAlignmentCenter;
[headerView addSubview:headerTitile];
headerTitile.font = [UIFont fontWithName:@"Arial" size:16.0f];
headerView.backgroundColor = [UIColor colorWithRed:48/255.0f green:119/255.0f blue:21/255.0f alpha:1];
return headerView;
}
我越来越像上图了,我不想隐藏空值标题。
【问题讨论】:
-
你可以检查它是否为空 set tableView:heightForHeaderInSection: return 0 还有 tableView:viewForHeaderInSection: return [[UIView alloc] initWithFrame:CGRectZero]
标签: ios objective-c iphone uitableview ios7