如何删除空的标题标题

我有一个表视图,因为我有标题标题,他们工作正常,但标题标题值的总和变为空,我想隐藏我的表视图中的空标题标题。 我怎么能做这个过程。 请帮我编码。 图片

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

我越来越像上面的图像,我ant隐藏空值标题标题。

如果没有对象,则在heightForHeaderInSection更改将返回0

 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { //Note use your main array which defines section's row and according to each section it may be dictionary or array use accordingly NSArray *arrObjects = yourSectionsRowData[section]; if([arrObjects count]>0]) return 60.0; else return 0.0; } 

如果在viewForHeaderInSection没有find任何对象,也返回视图nil

 -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { //Note use your main array which defines section's row and according to each section it may be dictionary or array use accordingly NSArray *arrObjects = yourSectionsRowData[section]; if([arrObjects count]>0]) return nil; else { 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; } }