Cœur
Cœur

Reputation: 38667

removing invisible header from ipad tableview

my UITableView has some kind of invisible header / inset on iPad and not on iPhone.

iphone tableView ipad tableView

I tried all the following to remove this unwanted header/inset, with no success:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableview.sectionHeaderHeight = 0.f;
    self.tableview.sectionFooterHeight = 0.f;
    self.tableview.tableHeaderView = nil;
    self.tableview.tableFooterView = nil;
    self.tableview.contentInset = UIEdgeInsetsZero;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.f;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"";
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [[[UIView alloc] initWithFrame:CGRectNull] autorelease];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [[[UIView alloc] initWithFrame:CGRectNull] autorelease];
}

Upvotes: 1

Views: 111

Answers (1)

Cœur
Cœur

Reputation: 38667

Ok, I finally found a way...

self.tableview.tableHeaderView = [[[UIView alloc] initWithFrame:CGRectMake(0.f, 0.f, 0.f, FLT_MIN)] autorelease];

You can't use: nil, CGRectNull, CGRectZero, or anything with a height of 0.f. So I used FLT_MIN to be as close to 0.f as possible.

Upvotes: 1

Related Questions