问题
Possible Duplicate:
Hide the status bar on iPhone on a single view?
I want to hide the title bar in iphone from my first welcome view and also from the splash screen, how can i hide it(top bar, not the navigation bar).
I saw a post with this
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
but this hides the title bar through out the application. I just want to hide it from the first view.
回答1:
The easiest way to hide the status bar is to go into youInfo.plist; right click to add a row and select Status Bar Initially hidden.
This will ensure every time you app launches the status bar will be hidden.
Edit
with programming
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 320, 44);
and when you want to show the statusbar just use bellow code..
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
self.navigationController.navigationBar.frame = CGRectMake(0, 45, 320, 44);
i hope this help you...
:)
回答2:
In AppDelegate class applicationDidFinishLaunching ,write the below code
- (void) applicationDidFinishLaunching:(UIApplication *)application
{
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
}
All other views (except first View) when you need to display StatusBar, write the below code in curresponding ViewDidiLoad() / viewWillAppear
,
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
回答3:
in your info.pist find this option. "Status bar is initially hidden" And set as YES.
回答4:
Depends which version of Xcode you are using.
In 4.5 you can go into the build settings "Summary" tab and set this in the "Status Bar" section.
If you don't have 4.5 then in the build settings "Info" section add a plist entry for "Status Bar Is Initially Hidden" and set it to YES. (Alternatively, download Xcode 4.5 because you should do this anyway).
来源:https://stackoverflow.com/questions/12929951/how-to-hide-the-title-bartop-bar-in-iphone-from-a-view