Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView partially hidden by UITabBar

I've got a UITabBarController which contains a UINavigationController. Within the visible UIViewController, I'm creating a UITableView programatically as follows:

self.voucherTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
self.voucherTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

However, the UITabBar is overlapping the UITableView.

When I output the height of the [[UIScreen mainScreen] applicationFrame], it returns 460.00 whereas it should be 367.00.

In Interface Builder, I'm using the 'Simulated Metrics' which automatically sets the height of the view to 367.00.

Is there something I'm missing, no matter what I try I can't see to get the 367.00 height that I need.

As a temp fix, I've set the frame of the UITableView manually, this isn't really ideal so it would be nice to work out why this isn't working:

self.voucherTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 367) style:UITableViewStylePlain];
like image 332
Dan Ellis Avatar asked Sep 14 '11 21:09

Dan Ellis


1 Answers

You should use self.view.bounds rather than [[UIScreen mainScreen] applicationFrame] as the last one returns you the whole screen frame while self.view.bounds provides you with your view bounds wich seems what you are searching for.

like image 165
Ariel Avatar answered Oct 17 '22 22:10

Ariel