tags:

views:

178

answers:

4
+1  Q: 

iPhone + UIView

Hi,

I am having a strange problem:

In -(void)viewWillAppear:(BOOL)animated method I use:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

It means I am hiding the StatusBar, since I am hiding it, all the controls in my View are shifted upside by some distance when I run the application so, it appears in different way than what I have designed in Interface Builder.

Please help me so that my StatusBar remains hidden and View (and its controls) are not shifted from their position

A: 

You could go into Interface Builder and add padding to anticipate the shift.

Alex Reynolds
How to add padding to anticipate the shift ?
pratik
Just add a transparent view at the top of your parent view.
Alex Reynolds
I am not getting what you are saying? Please can you elaborate it?
pratik
A: 

In your application's plist, add a new boolean with the key: UIStatusBarHidden and enable it. In interface builder, turn off the status bar. Now resize your views the way you want them in interface builder.

Sastira
I did the way you told but same result, the view is shifted up
pratik
As Mobs said below, set your view and window and everything that is 460 to 480 in height. You may have to do this manually by typing it in.
Sastira
A: 

set the view to 480 pixels high in IB rather than 460.

Mobs
+1  A: 

Don't hide the StatusBar in your viewWillAppear unless the StatusBar is meant to be hidden for some views and not others. Otherwise hide the status bar either in appFinishedLoading or using the info.plist, as mentioned below.

As for items shifting up, there is a lot you can do to prevent that. In Interface Builder you could check the property not to resize views. You can also create your views to be as big as the screen without the status bar. You can also tell your buttons, labels, etc. not to move by going into the Interface Builder layout window and clicking on the red arrows and lines that attach an object to edges of the screen.

mahboudz