I'm building an iOS 9 app with horizontal pages navigation and need to show the status bar on some pages, and hide it on others. I want to use the fade in/out animation so I have to set
View controller-based status bar appearance = NO
and update the status bar like this:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
This procedure works perfectly when navigating between pages, but I can't get rid of the status bar on launch.
I have tried setting: Status bar is initially hidden = YES
Adding this to the NavigationControllers viewDidLoad:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
self.statusBarHidden = YES;
[self setNeedsStatusBarAppearanceUpdate];
Adding this to AppDelegates didFinishLaunchingWithOptions:
application.statusBarHidden = YES;
Adding this to the ViewController of the initial page:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Checking the "Hide status bar" option in General->Deployment Info
And setting "Status Bar" to "None" in the linked storyboard element
But the status bar is still showing up on launch. How can I get rid of the status bar on launch without changing the value of View controller-based status bar appearance ?
Just tick the hide status bar in project setting as below.
Project setting - For hiding the status bar at launch of app.
Add below in viewController for which you need to hide.
- (BOOL)prefersStatusBarHidden {
return YES;
}
/------ UPDATE -----/
With tick of hide status bar
Without tick of hide status bar
/------ Animate Status Bar -----/
In plist.
View controller-based status bar appearance = NO
Then in viewWillAppear method.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
changing plist file :
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Goto Targets->General->Deployment Info: and under that select Hide Status Bar option.
Turns out what I was doing was correct, but there was an errant [[UIApplication sharedApplication] setStatusBarHidden:NO]; buried in inherited code. I grepped it, but overlooked that line...
(use git grep StatusBar to find lines of code in a git repo that mutate the status bar)
Also, the only code needed is:
View controller-based status bar appearance = NO (in plist)
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
anywhere the status bar needs updating (usually in viewWillAppear)
In order to achieve what you are looking for you need set in the app.plistfile:
Status bar is initially hidden to YES
View controller-based status bar appearance to NO
Then in every view controller to show it
[[UIApplication sharedApplication] setStatusBarHidden:NO];
or to hide it:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Related
getting strange issue in iOS 8
i have made made
View controller-based status bar appearance is NO in info.plist file
implemented following methods
-(void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
-(BOOL)prefersStatusBarHidden;
{
return YES;
}
the problem is when i navigate to photo gallery at time status bar is hidden , but after dismissing it , status bar became visible for entire app .
Thanks.
You need to hide status bar in view will apear of the class in which you are calling imagepicker using below code.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
From Plist
Status bar initially hidden Select YES
ViewController Based Status bar Set to NO.
it will work the trick.
I tried to add View controller-based status bar appearance: NO and Status bar is initially hidden: YES to plist, [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone] and - (BOOL) prefersStatusBarHidden to CCDirectorIOS and AppDelegate, no one works.
There's something I am missing?
Add below given function to CCDirector.m file.
(BOOL)prefersStatusBarHidden {return YES;}
In your Info.plist set Status bar is initially hidden to YES and View controller-based status bar appearance to NO.
See more here: https://www.makegameswith.us/gamernews/279/hiding-status-bar-ccmenu-fix-ios7
I changed the status bar text colour to white,when I open camera roll in my app, it again sets status bar text colour to black, and when I dismiss camera roll status bar in my app has black text.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
solved my problemmm
You can also do this with out writing code
On you project plist file:
Set the
Status bar style:
UIStatusBarStyleLightContent
View controller-based status bar appearance: NO
Status bar is initially hidden: NO
I have tried setting the following in my app .plist file:
View controller-based status bar appearance: NO
And while this removes it from my initial view controller, once I go to another view and come back with my navigation controller, it comes right back and this time it does not disappear. Also, I don't see why it would matter but I have also set the status bar under simulated metrics to "None" but that doesn't seem to help. I know i am going to have the navigation bar but the status bar I need gone.
How can I get this done? Please provide a detailed answer, sample code would be great!
Update: This is NOT a duplicate solution as I have tried all other solutions and NONE seem to work for me. Most recently I tried
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Again, with no results. When the app initially launches a status bar is NOT present, after the user visits another view, the status bar is now present in the 2 and other views and does not go away. Even if you go back to the main view.
I have tried all of the suggestions that were posted here, unfortunately what happened here was a small mistake, in my viewDidLoad I had:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
But in my viewWillAppear I had:
[[UIApplication sharedApplication] setStatusBarHidden:NO];
So this was just an issue of overriding, problem fixed now.
To hide status bar:
if [View controller-based status bar appearance: NO]: in AppDelegate.m call
[[UIApplication sharedApplication]setStatusBarHidden:YES];
else: in every view controller
- (BOOL)prefersStatusBarHidden
{
return YES;
}
Try this 2 steps:
In .Plist file of project set the property:
View controller-based status bar appearance = NO;
and
2.In all view controller's .m file in viewDidLoad method put this line of code:
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Use this method in the View Controller which you'd like the Status Bar hidden:
- (BOOL)prefersStatusBarHidden {
return YES;
}
This should work :
// In iOS7 this gets called and hides the status bar so the view does not go under the top iPhone
// status bar
- (BOOL)prefersStatusBarHidden {
return YES;
}
none of these work for me.
when i try this method i get the message "use of undeclared identifier preferstatusbarHidden
include - (BOOL)prefersStatusBarHidden {
return YES;
}
I don't know what to do anymore. I tried setStatusBarHidden, prefersHiddenStatusBar and still no results. Finally i have went through the below you tube link :
https://www.youtube.com/watch?v=FtpBXdMSqRQ
It worked for me.
I'm trying to hide the status bar in iOS 4.3 now that setStatusBarHidden:animated: is deprecated:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; //deprecated
The only option that exists in the plist file is: Status bar is initially hidden. Which only hides the status bar at the start of the app.
Cheers
Try this:
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
From Apple Class Reference:
setStatusBarHidden:withAnimation:
Hides or shows the status bar,
optionally animating the transition.
- (void)setStatusBarHidden:(BOOL)hidden
withAnimation:(UIStatusBarAnimation)animation
Parameters
hidden
YES to hide the status bar, NO to show the status bar.
animation
A constant that indicates whether there should be an animation and, if
one is requested, whether it should
fade the status bar in or out or
whether it should slide the status bar
in or out.
But how about [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
See the UIApplication reference.
The new method is:
- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation
Works the same except the animation type is an enum now to support various animation types.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
seStatusBarHidden seems to be deprecated and not working anymore.
Use prefersStatusBarHidden on your view controller instead
- (BOOL)prefersStatusBarHidden
{
return YES;
}