tableHeaderView的高度似乎是0
-
20-09-2019 - |
题
我试图覆盖第二tableHeaderView。但似乎它在方法的高度heightForHeaderInSection似乎是0.不能解释它,我必须把它放在一个伊瓦因为viewForHeaderInSection我可以设置没有任何问题的看法。
- (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
有一个tableHeaderView
,然后依赖于viewForHeaderInSection
和heightForHeaderInSection
方法将每个部分自定义标题的观点,否则你只是用titleForHeaderInSection
在那里放置文本。
不隶属于 StackOverflow