I read lot's of answers how to hide status bar on iPad in iOS 7.0 but nothing works. My app is an iPhone app only, and it's deployment target is set to 6.0 . On iPhone 6.0 , 7.0 and iPad 6.0 status bar is hidden, but on iPad with iOS 7.0 isn't.
Try:
Option1:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Use this code in the rootViewController of your app
Option 2:
In info.plist file add a row for "View controller-based status bar appearance" and set it to NO
Option 3:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Try these properties in the plist also for iPad 7.0
Status bar is initially hidden = YES
View controller-based status bar appearance = NO
Try if add this to hide the status bar if you use "View controller-based status bar appearance" to NO.
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application setStatusBarHidden:YES];
return YES;
}
I always use this snippet:
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]){
[self prefersStatusBarHidden];
}
else{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
[self setNeedsStatusBarAppearanceUpdate];
And implement this method:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Try adding this method to your ViewController , it worked for me
- (BOOL)prefersStatusBarHidden
{
return YES;
}
Related
I want to hide staus bar in single view controller but my code is not working.
I'm using the below code
-(BOOL)prefersStatusBarHidden
{
return YES;
}
&
-(void)viewWillApper:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
or
in
application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write
[[UIApplication sharedApplication] setStatusBarHidden:YES];
or
Add following line in viewdidload
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];
and add new method
- (BOOL)prefersStatusBarHidden {
return YES;
}
if you have View controller-based status bar appearance set to YES in app's plist, put this code in the view controller:
- (BOOL)prefersStatusBarHidden {
return YES;
}
and if View controller-based status bar appearance is set to NO, do the following whenever you want to hide the status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
try this one it's help for me-:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
To hide status bar on a single VC:
1) Add this value to plist:
"View controller-based status bar appearance" and set it to "YES"
2) Add following to viewWillAppear:
[self prefersStatusBarHidden];
3) Add new method:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
This question already has answers here:
How to hide status bar in UIImagepickercontroller?
(13 answers)
Closed 8 years ago.
How to hide "Status Bar" when appear UIImagepickerController?
Here i using iOS coding and xcode 5.
In a view has two buttons one for camera and another gallery. this view would be showed status bar always.
When user press camera button then will appear camera. but it is showed status bar. After take photo will disappear to view.
I would be like hide "Status Bar" when appear Camera. Is there any code?
**Try this Code :-**
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
//iOS 7 into set this property in info.plist file.
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Please try this one :
First set in your .plist file.
'View controller-based status bar appearance' and set to NO.
Add in your AppDelegate Method
[application setStatusBarHidden:NO];
[application setStatusBarStyle:UIStatusBarStyleDefault];
If you want to change statsubar color change the setStatusBarStyle according to your app background color.
Also you can try:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
Solution
Go to your plist file and add a new row, View Controller-Based Status Bar Appearance
This should handle this problem.
put this line in your camera button method
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
you add this code
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if(IS_IOS_7){
if ([navigationController isKindOfClass:[UIImagePickerController class]] &&
((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
}
}
i want to hide status bar hidden in both ios 6.0 and ios 7.0.
please can you explain any common method which work in both ios version for ios.
please provide solution :-
thanks.
Update In Plist add these property.
Status bar is initially hidden = YES
View controller-based status bar appearance = NO
Programatically
- (void)viewDidLoad {
[super viewDidLoad];
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)])
{
[self prefersStatusBarHidden];
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
}
else
{
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
} }
// add this too
- (BOOL)prefersStatusBarHidden {
return YES; }
I have the following code
else {
if ([[UIApplication sharedApplication] isStatusBarHidden]) {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
_navigationBar.hidden = NO;
_navigationControl.hidden = NO;
} else {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
_navigationBar.hidden = YES;
_navigationControl.hidden = YES;
}
}
If I compile it, it works fine in iOS6 but it doesn't in ios7. The navbar is meant to appear when the user taps on the screen.
Any idea?
Thanks!
In your info.plist file set the key, "View controller-based status bar appearance" to NO.
In my UIViewController, I have:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[self.view sizeToFit];
}
Yet the view looks like this:
I'm sure this code runs. I load the view from a xib. I haven't done anything else to the status bar like change its style. What could be wrong?
Even when I set `application.statusBarHidden = YES" in my app delegate, I see:
In your app's plist, if you have "View controller-based status bar appearance" set to YES, put this code in the view controller in which you hide the status bar:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Else if "View controller-based status bar appearance" is set to NO, call the following whenever you want to hide the status bar.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
if you want to hide Status Bar in your app , Follow this steps :
Step 1 :
Step 2:
Step 3:
Add to your appDelegate didFinishLaunchingWithOptions function
application.statusBarHidden = YES;
so :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.statusBarHidden = YES;
}
That's because iOS 7 has changed the way it deals with the status bar.
Setting UIViewControllerBasedStatusBarAppearance to NO on your app Info.plist should work.
You can show/hide your app status bar using the following code (Works on IOS 7 - IOS 8 and IOS 9):
in your project .h file add this boolean:
BOOL isShowStatus;
And in .m file add this:
//To show the status bar:
-(void)showTheStatusBar
{
isShowStatus = YES;
[self setNeedsStatusBarAppearanceUpdate];
}
//And to hide the status bar:
-(void)hideTheStatusBar
{
isShowStatus = NO;
[self setNeedsStatusBarAppearanceUpdate];
}
- (BOOL)prefersStatusBarHidden {
return !isShowStatus;
}
Simply call it from anywhere, didload for example:
- (void)viewDidLoad
{
[super viewDidLoad];
//To show the status bar:
[self showTheStatusBar];
//Or to hide it:
[self hideTheStatusBar];
}
For me it works fine:
- (BOOL)prefersStatusBarHidden {
return YES;
}
ALWAYS in the root view. If you are doing that in a subview will not work because status bar visibility will be taken from parent view.
Try adding this after you hide the status bar:
[self.view setFrame:[self.view bounds]];
In your appdelegate.m in didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
application.statusBarHidden = YES;
}
When I run your code: