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的返回类型:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。