Height of tableHeaderView seems to be 0
Posted
by gabac
on Stack Overflow
See other posts from Stack Overflow
or by gabac
Published on 2010-03-15T22:37:36Z
Indexed on
2010/03/15
22:39 UTC
Read the original article
Hit count: 358
I tried to override the second tableHeaderView. But it seems that the height of it in the method heightForHeaderInSection seems to be 0. Can't explain it, do I have to put it in a iVar because in the viewForHeaderInSection I can set the view without any problems.
- (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;
}
© Stack Overflow or respective owner