"Resize UITableView to fit toolbar"

Tue 12 May 2009

CGFloat toolbarHeight = 50;

CGRect mainViewBounds = self.view.bounds;

[toolbar setFrame:CGRectMake(CGRectGetMinX(mainViewBounds),

CGRectGetMinY(mainViewBounds) + CGRectGetHeight(mainViewBounds) - (toolbarHeight),

CGRectGetWidth(mainViewBounds),

toolbarHeight)];

 

 

UIView *footerView = [[[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(mainViewBounds), 

CGRectGetMinY(mainViewBounds), 

CGRectGetWidth(mainViewBounds), 

toolbarHeight+5)] autorelease];

 

tableView = [[UITableView alloc

initWithFrame:CGRectMake(mainViewBounds.origin.x, mainViewBounds.origin.y, mainViewBounds.size.width, mainViewBounds.size.height - toolbarHeight -5

style:UITableViewStyleGrouped];

tableView.delegate = self;

tableView.dataSource = self;

tableView.tableFooterView = footerView;

tableView.backgroundColor = [UIColor clearColor];

[self.view addSubview:tableView];