次のようにカスタム viewForHeaderInSection を実装しました。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
CGRect sectionFrame = CGRectMake(0, 0, tableView.bounds.size.width, 30.0f);
float xInset = 16.0;
RTUTableHeaderView
*headerView =
[[RTUTableHeaderView alloc] initWithFrame:sectionFrame
andBackgroundColor:[UIColor clearColor]
FontColor:[RTUColorHelper kSettingsTableCellFontColor]
andFontSize:18.f
withLabelFrame:CGRectMake(xInset, 10.f, sectionFrame.size.width - xInset, 20)];
headerView.label.text = [self tableView:tableView titleForHeaderInSection:section];
return headerView;
}
これにより、ラベルが 10 ポイント押し下げられ、関連するセクションの近くに配置されます。iOS6 では問題ないように見えますが、iOS7 では、最初のセクション ヘッダーのラベルが他のヘッダーよりも約 10 ポイント上にあります。10pt のオフセットを取り除くと、最初のセクションのラベルは headerView の上部に配置されますが、他のセクションはヘッダー フレームの垂直方向の中央に配置されます。
セクション 0 の値がバグである場合は、値を変更することもできますが、そうしないことは明らかであり、何か他のことを忘れていないか、何か間違ったことをしていないかを確認したかったのです。
セクション ヘッダーはすべて同じ高さです。heightForRowAtIndexPath は 44.f を返します。