How to hide status bar in UIImagepickercontroller? How to hide status bar in UIImagepickercontroller? objective-c objective-c

How to hide status bar in UIImagepickercontroller?


This worked fine for me:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{    [[UIApplication sharedApplication] setStatusBarHidden:YES];}

Edit: As of today i just found out that in your info.plist, if you just copy-paste view controller-based status bar appearance there it won't work ... you have to hit enter on a property, and scroll to the last one of them so you will have autocomplete to :view controller-based status bar appearance and an boolean, with no. I tried multiple times but it does not work just copying. Have a nice day.


The solution I found for applications build around :"View controller-based status bar appearance" set to YES

I did add Category:

//UIImagePickerController+StatusBarHidden.h#import <UIKit/UIKit.h>@interface UIImagePickerController (StatusBarHidden)@end//UIImagePickerController+StatusBarHidden.h#import "UIImagePickerController+StatusBarHidden.h"@implementation UIImagePickerController (StatusBarHidden)-(BOOL) prefersStatusBarHidden {    return YES;}-(UIViewController *) childViewControllerForStatusBarHidden {    return nil;}@end

The method childViewControllerForStatusBarHidden is used rarely, but image picker do use it, thats why might cause some troubles

You may also implement UIViewController singleton, with method which returns YES or NO, based on its property.Then your View controleller implements childViewControllerForStatusBarHidden returning the above singleton.Changing singleton property automatically change statusbar in app. There also is twin method childViewControllerForStatusBarStyle


However for 2014, iOS8, see this https://stackoverflow.com/a/18960308/294884


I had an issue where in iOS7 my status bar was not being hidden. I hid it programmatically and it still displayed in iOS7, but when ran in iOS6 the status bar would hide appropriately. You have to go to the plist and add the following:

'view controller-based status bar appearance' and set to NO.

If you want the status bar to re-appear in other view controllers and only be hidden on a particular VC, then you set the status bar to hidden YES when the VC loads. When the VC will disappear you set the status bar hidden back to NO.

- (void)viewDidLoad{    [super viewDidLoad];    [[UIApplication sharedApplication] setStatusBarHidden:YES];}

and when the controller will disappear you add the following to set the status bar so it is no longer hidden and will display on the next View:

-(void)viewWillDisappear:(BOOL)animated{     [[UIApplication sharedApplication] setStatusBarHidden:NO];}

setStatusBarHidden:withAnimation: if you want some smooth animation