tableHeaderViewの高さは0であると思われます
-
20-09-2019 - |
質問
私は2番目のtableHeaderViewを上書きしようとしました。しかし、それは私がviewForHeaderInSectionに、私は何の問題もなくビューを設定することができますので、IVARに入れなければならないのは、この方法でそれの高さはheightForHeaderInSection 0がそれを説明することはできませんのようだと思われます。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
return @"Adding a new list";
else
return @"Other lists";
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section == 0) {
return tableView.tableHeaderView;
} else {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)] autorelease];
view.backgroundColor = [UIColor redColor];
return view;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 0)
return tableView.tableHeaderView.frame.size.height;
else
return 30;
}
解決
私は、彼らが異なっている、あなたは、テーブルヘッダと各セクションのヘッダーが混乱していると思います。何の「第二tableHeaderViewは」UITableView
は1 tableHeaderView
があり、その後、そうでなければ、ただそこにテキストを配置するviewForHeaderInSection
を使用し、各セクションのカスタムヘッダービューを配置するheightForHeaderInSection
とtitleForHeaderInSection
方法に依存して、ありません。
所属していません StackOverflow