2

I'm so confused. I don't have a status bar, and I don't know how to make my scroll view's dimensions. Is it 320 x 480, or 320 x 460? Because when I drag it out onto storyboard and it fills the entire screen it says it is 320 x 460, but then when I add subviews to it they get positioned strangely and so that it's like the views are 20 pixels short or something.

EDIT: I'm just a little confused because when my status bar goes away, it doesn't re adjust the view size, it just makes the view 20 pix shorter, which doesn't really make sense, right? Shouldn't it make it 20 pix longer instead of just cutting off 20 pix?

bmende
  • 741
  • 1
  • 11
  • 24

3 Answers3

7

The iPhone screen is 320x480 definitely.

The reason you're having an issue in storyboards is there are multiple places to tell it you don't have a status bar. You need to track down all of them (3?) and make sure it says no status bar.

The most common problem is that you have your status bar either on or inferred in one of your earlier viewControllers while you've exclusively set it to off in a nested viewController. This causes it not to have a status bar but show itself as 460 pixels high. as you can see in the image its clearly 20 pixels shorter. Thats because the segue is telling it that when its presented to present it "under" the status bar even though it doesn't have one itself. If I were to change the segue from a modal to push the problem goes away. Or if I set the first viewController to have no statusBar as well the problem goes away. Also note that Xcode can require a restart to properly update its graphical storyboard in some instances.

enter image description here

One More Thing

Also setting either in code or storyboards to hide the status bar isn't the same as setting the UIStatusBarHidden to YES in your .info file. If you left it to no while hiding it everywhere else your default.png will be clipped and show the status bar while loading then it will disappear once the app finishes launching. So be sure to hide it there as well for a consistent user experience.

Code

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [application setStatusBarHidden:YES];
}
Ryan Poolos
  • 18,421
  • 4
  • 65
  • 98
  • I believe if you set it in code in the app delegate it overrides that – Dan F Aug 02 '12 at 19:57
  • Yea pretty much but you should be able to do it entirely in storyboards. I've updated my answer with a picture and very detailed steps on why its happening. – Ryan Poolos Aug 02 '12 at 19:59
  • Well, all i did to tell it that the status bar is gone is i went in the plist and typed in a command, status bar is initially hidden, and i set it to YES, wont that work? So how come when i drag it out on storyboard and it fills the entire screen, the size is only 320 x 460? should i just change it to x:0 y:0 width 320 height 480 even tho it looks like its going off screen on the story board? – bmende Aug 02 '12 at 19:59
  • I've updated my answer with more info. Setting the status bar to be initially hidden isn't exactly the same thing as hiding it elsewhere. In fact you can hide and show it on command through the app if necessary. So if you want it entirely hidden for good its best practice to do it in the .info, storyboard and App Delegate code. – Ryan Poolos Aug 02 '12 at 20:02
  • ok so in ib i saw my status bar was set to inferred, so now i just changed it to none for all my vcs, which is good, right? and now please tell me how to change it in app delegate code – bmende Aug 02 '12 at 20:09
  • Why does apples website state the resolution as 640x960, which is double this? – Buttle Butkus Jun 03 '15 at 08:38
  • Thats the native screen resolution, not the point resolution available for programming. – Ryan Poolos Jun 03 '15 at 23:08
3

it is 320 x 480, the 20 pixels you are seeing is the status bar, if you are planning on hiding the status bar and want to match the size in Interface Builder, you can go to IB to Simulated Metrics -> Status Bar and select None.

This will not affect the real size of the view in your view controller, though as it will resize itself to fit in the size even if you set the view to be 320 x 480, the view controller will resize itself to 320 x 460 if there is a status bar and 320 x 418 if there is also a navigation bar.

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
1

I am a bit out of iPhone-programming, but this 20px should be the upper border, where you can see the carrier and strength etc.

nico
  • 1,039
  • 4
  • 13
  • 27