Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 - Hide status bar on certain view

This is a rather unique question. I have searched for hours and could not find the answer. I want ALL UIViewControllers in my app to have the UIStatusBar visible. But on a certain UIViewController, when you tap a UIButton, the following method calls the camera modalView controller. I want to hide the status bar when the following method is called:

-(BOOL)startCameraControllerFromViewController:(UIViewController*)controller
                                 usingDelegate:(id )delegate 

I have tried changing the plist file with UIViewController based status bar = YES (I only want the UIStatusBar hidden when that modal view is pulled up)

I have also tried the following within the above method:

[[UIApplication sharedApplication] setStatusBarHidden:YES 
                                   withAnimation:UIStatusBarAnimationNone];
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {

    [[UIApplication sharedApplication] setStatusBarHidden:YES 
                                       withAnimation:UIStatusBarAnimationNone];

Nothing seems to work. Can anyone help?

like image 771
Josue Espinosa Avatar asked Oct 04 '13 05:10

Josue Espinosa


People also ask

How do I hide my status bar on iPhone 7?

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.


2 Answers

Implement this method in your View Controller,

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

and call this method where you want,

[self prefersStatusBarHidden];
like image 93
karthika Avatar answered Oct 10 '22 12:10

karthika


Solved it by subclassing the UIImagePickerController and just adding this to the .m file:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

then importing it to the class that uses the picker, and instead of initializing the imagepicker i initialize the subclass.

NOTE: make sure View controller-based status bar appearance is set to YES in your plist file.

like image 45
Josue Espinosa Avatar answered Oct 10 '22 13:10

Josue Espinosa