UITableViewCell标签在我滚动时调整大小

UITableViewCell标签在我滚动时调整大小,uitableview,Uitableview,我正在尝试创建一个带有UITableView的排名表 我创建了一个自定义单元格,有7个标签。我使用分组单元格来区分AL Central、NL East等 当我加载视图时,请查看此图像: 将其与我滚动视图时的图像进行比较: 这是我的代码删除了重复的代码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *Ce

我正在尝试创建一个带有UITableView的排名表

我创建了一个自定义单元格,有7个标签。我使用分组单元格来区分AL Central、NL East等

当我加载视图时,请查看此图像:

将其与我滚动视图时的图像进行比较:

这是我的代码删除了重复的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSString *CellIdentifier = @"Cell2";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    // Configure the cell...
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                    }// end



    //rank
    UILabel *rank = (UILabel *)[cell viewWithTag:101];
    //team
    UILabel *team = (UILabel *)[cell viewWithTag:102];



    if(indexPath.row == 0)
        {

        NSArray *division = @[@"AL Central", @"AL East", @"AL West", @"NL Central", @"NL East", @"NL West"];


            rank.text = @"";
            team.text = division[indexPath.section];

            cell.backgroundColor = textPrimary;
            team.textColor = backgroundPrimary;

            team.font = [UIFont boldSystemFontOfSize:5.0f];
            won.font = [UIFont boldSystemFontOfSize:11.0f];

            return cell;

        }



    cell.backgroundColor = [UIColor clearColor];


    rank.textColor = textPrimary;
    team.textColor = textPrimary;

    int new_row = indexPath.row + indexPath.section*5 - 1;

    rank.text = [[[dataSource objectAtIndex:new_row] objectForKey:@"rank"] stringValue];
    team.text = [[dataSource objectAtIndex:new_row] objectForKey:@"first_name"];

    return cell;
}

我解决了这个问题,在字体不是标题时再次设置字体:

        team.font = [UIFont systemFontOfSize:5.0f];