Ios 如何在UITableView中删除空节标题

Ios 如何在UITableView中删除空节标题,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有一个UITableView,因为我有三个标题标题。问题是:当我的标题标题值变为空时,意味着标题不应显示在表视图中。我试过很多方法,但对我没有帮助。谁能帮帮我吗 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [reverseOrder1 objectAtIndex:section]; } - (CGFloat)tableView:(UIT

我有一个UITableView,因为我有三个标题标题。问题是:当我的标题标题值变为空时,意味着标题不应显示在表视图中。我试过很多方法,但对我没有帮助。谁能帮帮我吗

- (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;

}
你可以这样用

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
     {

    if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section == 0]) 
    {
        return 0;
    } 
    else
     {
        return 60;
     }
    }

除了Ravi的答案外,请确保在情节提要中将“表视图”的“截面高度”属性设置为0。

Posable duplicate。在你提问之前请先搜索你的桌子上有多少部分?@AbhishekNath 3部分bro@huynghia我已经尝试过这个链接,它对我没有帮助[reverseOrder1 objectAtIndex:section]是NSString吗?当标题为“零”时是否要删除标题?当[reverseOrder1 objectAtIndex:section]为零时,请尝试将viewForHeaderInSection:返回nil heightForHeaderInSection:=0。nilIt至少强制值为1