- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(section != 0) {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)] autorelease];
view.backgroundColor = [UIColor redColor];
return view;
} else {
return tableView.tableHeaderView;
}
}
これはviewForHeaderInSectionの実装ですが、どのフレームを作成しても、常に同じ赤いフレームが表示されます。私のコードに問題がありますか?
画像:
アップデート:
Mhm今、私の赤いブロックは高くなっていますが、私の最初のtableHeaderはどういうわけか隠されています。最初のものは、titleForHeaderInSectionで実装されました。tableHeaderの高さを実装するだけだと思ったのですが、うまくいきません
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 1)
return 30;
else
return tableView.tableHeaderView.frame.size.height;
}