Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad Application is offset by 20 pixels

I am using the code below to create a splash screen image. The only problem I am running into is that the view then appears 20 pixels below the top of the of screen. Upon inspecting the properties of the appFrame, I can see that the origin and the height are incorrect. When I load my next view, it adds to that 20 pixels and becomes 40 pixels! What am I doing wrong here? What is causing the 20 pixel gap?

CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
UIView *view = [[UIView alloc] initWithFrame:appFrame];
view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.view = view;

splashImageView_ = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splashpage.png"]];

enter image description here

like image 329
atrljoe Avatar asked Apr 06 '26 16:04

atrljoe


2 Answers

the frame for the main screen is relative to its superview, so it includes a 20px offset for the status bar. When you set that as your frame, you are saying that your view should be have an origin 20px below the top of its superview

you should set the frame of your view as the bounds of the screen

like image 99
wattson12 Avatar answered Apr 12 '26 22:04

wattson12


you can set the "Status bar Initially Hidden" Property to "YES" in Info.plist file in your Application.

iOS will take it off for you and readjust your screen size

like image 43
Leonardo Baptista Avatar answered Apr 13 '26 00:04

Leonardo Baptista