简体   繁体   中英

iPhone + UIView

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

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.

您可以进入Interface Builder并添加填充以预期变化。

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.

在IB中将视图设置为480像素高,而不是460。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM