views:

194

answers:

2

In the viewDidLoad method I add any combination of these and I can't get it to work:

 CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
 [[self tableView] setBounds:appFrame]; 
 // self.view.frame = appFrame;
// self.view.bounds = appFrame;
// [[self tableVew] setFrame:appFrame];
 self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

There is always a 20px gap at the top with my previous screen showing through.

+3  A: 

The 20px is the room for the status bar (the docs on -applicationFrame cover this). Have you turned off the status bar (with -setStatusBarHidden:animated:)?

Rob Napier
I did not hide the status bar. It is still visible.The gap with my old screen showing is just below the status bar.You are probably right an it has something to do with the status bar.
Bryan
The problem is that the applicationFrame provides 20px offset for the statusbar. You're then applying that frame to a view that itself is inside another view (the window if nothing else probably), and so your new frame is offset from your parent by the 20px. You actually want to set your frame to be the size of your parent's frame (or ultimately the window's frame). The window is already full screen. What is the "previous screen" you mention here?
Rob Napier
Thanks Rob. The previous screen was another viewController - my main game screen. The screen I am working with is the result screen. Your advise here led immediately to my solution below. Thanks.
Bryan
A: 

Instead of setting the bounds to the application frame: CGRect appFrame = [[UIScreen mainScreen] applicationFrame]; I set the bounds to the application bounds: CGRect appFrame = [[UIScreen mainScreen] bounds];

Then I set that to the bounds of my tableview [[self tableView] setBounds:appFrame];

Bryan