Alex Rivera | Logout

Hide the status bar on iPhone on a single view?

Asked 2011-11-30T13:36:57.640
32

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.

Edit
Report

1 Answer

0

Here is a snippet of code that might help. When the view loads show the status bar, when you leave the view hide it again.

-(void)viewWillAppear:(BOOL)animated {
    if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: withAnimation:)])
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
    else 
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
}


-(void)viewWillDisappear:(BOOL)animated  {
    if([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarHidden: withAnimation:)])
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
    else 
        [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
}
answered 2011-11-30T15:19:50.000

Your Answer