Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the status bar on iPhone on a single view?

I want to show the status bar in my app in all views but one. I have tried modifying the 'status bar is initially hidden' in the plist, i have tried:

[[UIApplication sharedApplication] setStatusBarHidden:YES];

That hides the bar but leaves an ugly blue box where the status bar was (which isn't part of my view, there's nothing blue on there).

I have also tried altering the layout wants full screen and status bar settings in the 'interface builder' bit of Xcode 4.2.

Any suggestions?

EDIT - SORT OF SOLUTION:

I have done it by including:

    -(void)viewWillDisappear:(BOOL)animated{


    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}


-(void)viewDidAppear:(BOOL)animated{


    [[UIApplication sharedApplication] setStatusBarHidden:NO];

}

on every single page that I want the status bar to be on.

It still looks choppy and rubbish because the tab bar appears and reappears each time you switch a view. But i've had enough, worked on this stupid problem for about 5 hours now so this will have to do.

SECOND EDIT -

Fixed the choppyness by including setStatusBarHidden=NO in viewWillAppears. God knows how everything works but it does.

like image 417
Adam Waite Avatar asked Nov 30 '11 13:11

Adam Waite


People also ask

How do I make the status bar disappear on my iPhone?

To completely hide it on the home screen, open up an app, such as Settings, and wait about three to four seconds. Press the home button again, and the status bar will be completely gone.

Can you customize iPhone status bar?

You can select from several preset Focuses, such as driving, working out, or reading, or you can set a custom Focus for something you often do. Within the settings it lets you add an identification icon that will appear in the status bar while in use. The trick is you don't actually have to set anything to turn off.

How do I change the color of my status bar on my iPhone?

Go to the Storyboard. Select the View and in the Attributes Inspector change the Background Color to Light Gray. Build and Run the Project. The default style of the status bar is dark content.


2 Answers

Try This one It will Run perfectly..

[[UIApplication sharedApplication] setStatusBarHidden:YES]; 

And in XIB set none option for the status bar.

for iOS 7.

Go to info.plist and add two attributes if not present. set "Status bar is initially hidden" to "YES" and set "UIViewControllerBasedStatusBarAppearance" to "NO". This will hide status bar for your app.

like image 177
Kartik Avatar answered Sep 22 '22 20:09

Kartik


#pragma mark - Hide statusbar

-(void)hideStatusBar {
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000
    // iOS 7.0 or later
    [self setNeedsStatusBarAppearanceUpdate];
#else
    // less than 7
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
#endif
}

- (BOOL)prefersStatusBarHidden {
    return YES;
}
like image 42
neoneye Avatar answered Sep 19 '22 20:09

neoneye