Sunday, May 22, 2011

Top of View Cut Off Under Status Bar

In trying to place an ad at the bottom of a view, I had the following code to determine the screen height:

if (!app.statusBarHidden) {
statusBarHeight = 20;
}
    return ([UIScreen mainScreen].bounds.size.height - statusBarHeight);

This returned a height of 460 as expected.  However, my ad appeared 20pts above the bottom of the screen.  I tried everything in Interface Builder from adding the status bar to the nib, taking out the status bar and setting the views frame height to 460, and changing the springs and scales.

What worked is setting the frame in viewWillAppear:
- (void)viewWillAppear:(BOOL)animated {
 // to fix the controller showing under the status bar
 self.view.frame = [[UIScreen mainScreen] applicationFrame];
}


As found on this thread:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/40582-top-view-cut-off-under-status-bar-interface-builder.html

No comments:

Post a Comment