views:

349

answers:

1

Hey all,

I'm building a UITableView programmatically without NIB files here. I'm doing something silly however, as my navigationBar shows up fine, as does my UITableView. However, the UITableView is not properly fitting onto the screen. You'll see roughly 20 pixels separating the UINavigationBar and the UITableView. I set my window's backgroundColor to black, as you can see in this screen shot: http://bit.ly/hXnvy

Here's the code to reproduce the problem:

- (void)loadView
{
 [super loadView];
 // TableViews that wish to utilize tableView footers/headers should override this method.

 UITableView *aTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
 aTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
 aTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;

 aTableView.delegate = self;
 aTableView.dataSource = dataSource;

    self.tableView = aTableView;
 [self.view addSubview:self.tableView];
 [aTableView release];

 // style navigation bar.
 //self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
}
+1  A: 

use bounds instead of applicationFrame

CiNN
That did it, but I'd like to understand further. I thought applicationFrame is the window occupying the screen minus the navigationBar?
Coocoo4Cocoa
the problem is the origin, aTableView uses self.view as it's origin, so in fact you should use [self.view bounds]
CiNN