ios – UITableView节头与64位iPad上的行重叠. 32位工作正常

前端之家收集整理的这篇文章主要介绍了ios – UITableView节头与64位iPad上的行重叠. 32位工作正常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
32位iPad:

64位iPad:

这是代码

- (float) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40.0;
}

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,tableView.frame.size.width,40)];

    [headerView setBackgroundColor:[UIColor grayColor]];

    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,113,headerView.frame.size.height)];
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.numberOfLines = 0;
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.text = @"Name";
    [headerView addSubview:nameLabel];

    nameLabel = [[UILabel alloc] init];
    nameLabel.numberOfLines = 0;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.frame = CGRectMake(175,50,headerView.frame.size.height);
    nameLabel.text = @"Risk Level";
    [headerView addSubview:nameLabel];

    nameLabel = [[UILabel alloc] init];
    nameLabel.numberOfLines = 0;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.frame = CGRectMake(220,headerView.frame.size.height);
    nameLabel.text = @"Code";
    [headerView addSubview:nameLabel];

    nameLabel = [[UILabel alloc] init];
    nameLabel.numberOfLines = 0;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.frame = CGRectMake(280,60,headerView.frame.size.height);
    nameLabel.text = @"Currency";
    [headerView addSubview:nameLabel];

    nameLabel = [[UILabel alloc] init];
    nameLabel.numberOfLines = 0;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.frame = CGRectMake(420,100,headerView.frame.size.height);
    nameLabel.text = @"Issuer";
    [headerView addSubview:nameLabel];

    return headerView;
}

解决方法

找到了解决方案.

不得不使用CGFloat而不是float作为heightForHeaderAtSection的返回类型:

原文链接:https://www.f2er.com/iOS/330901.html

猜你在找的iOS相关文章