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
Related
I need to change status bar style depending on the view controller so in my plist-file "View controller-based status bar appearance" is set to YES.
And I need to sometimes hide the status bar!
I'm trying to use setStatusBarHidden but it seems to work only if "View controller-based status bar appearance" is set to NO ...
So is there a way to hide the status bar ?
First, declare a variable to indicate hidden or not:
#interface ExampleViewController
{
BOOL statusBarHidden;
}
Second, override UIViewController's method which depends the variable:
- (BOOL)prefersStatusBarHidden {
return statusBarHidden;
}
Finally, when you need to hide status bar, do:
statusBarHidden = YES;
[self setNeedsStatusBarAppearanceUpdate];
When you need to display status bar again, do:
statusBarHidden = NO;
[self setNeedsStatusBarAppearanceUpdate];
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];
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 can hide a status bar in my app:
- (void)viewDidLoad{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[super viewDidLoad];
}
When I chose my launch image and start it first time, it's status bar over a picture. How can I hide this?
You need to add this code in your AppDelegate file, not in your Root View Controller
Or add the property Status bar is initially hidden in your plist file
Folks, in iOS 7+
please add this to your info.plist file, It will make the difference :)
UIStatusBarHidden
UIViewControllerBasedStatusBarAppearance
For iOS 11.4+ and Xcode 9.4 +
Use this code either in one or all your view controllers
override var prefersStatusBarHidden: Bool {
return true }
Add the following code to your view controller:
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
What helped me is this (changing plist file):
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Put this code to your view controller in which you hide status bar:
- (BOOL)prefersStatusBarHidden {return YES;}
In iOS 7 status bar appearance depends on UIViewController as default. To hide status bar globally, in info.plist use NO value for UIViewControllerBasedStatusBarAppearance key and use UIApplication's setStatusBarHidden method with YES BOOL value.
add this key key from dropdownlist in "info.plist" and voila you will no more see top bar that includes elements something like GSM,wifi icon etc.
It's working for me ,
Add below code into the info.plist file ,
<key>UIStatusBarHidden</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Hopes this is work for some one .
In info.plist
View controller-based status bar appearance NO
Status bar is initially hidden YES
In view controller.m
- (BOOL) prefersStatusBarHidden
{
return YES;
}
I am supporting iOS 5, 6, & 7. My app is iPad only. I needed to use all of the following:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
View Controller:
- (BOOL)prefersStatusBarHidden{ return YES; }
Info.plist
<key>UIStatusBarHidden</key>
<string>YES</string>
<key>UIStatusBarHidden~ipad</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<string>NO</string>
Just check the box on Targets/Summary iPad Deployment Info and you status bar will disappear.
It works on my apps.
I had the same problem, but its an easy fix! Just set
status bar is initially hidden = YES
then add an row by clicking on the plus right after the text status bar is initially hidden, then set the text to
view controller-based status bar appearance
by clicking the arrows, and set it to NO
Hope this helps!
Well the easiest way that I do it is by typing the following into the .m file.
- (BOOL) prefersStatusBarHidden
{
return YES;
}
This should work!
-(void) viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
A complete solution in swift, in your view controller
// you can use your own logic to determine if you need to hide status bar
// I just put a var here for now
var hideStatusBar = false
override func preferStatusBarHidden() -> Bool {
return hideStatus
}
// in other method to manually toggle status bar
func updateUI() {
hideStatusBar = true
// call this method to update status bar
prefersStatusBarHidden()
}
To hide status bar for each individual view controller programmatically, use any of the following two procedures:
Procedure 1:
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Procedure 2:
-(BOOL)prefersStatusBarHidden {
return YES;
}
To hide status bar for the entire application, we should follow the given below procedure:
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
Click here to view screenshot
I can hide a status bar in my app:
- (void)viewDidLoad{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[super viewDidLoad];
}
When I chose my launch image and start it first time, it's status bar over a picture. How can I hide this?
You need to add this code in your AppDelegate file, not in your Root View Controller
Or add the property Status bar is initially hidden in your plist file
Folks, in iOS 7+
please add this to your info.plist file, It will make the difference :)
UIStatusBarHidden
UIViewControllerBasedStatusBarAppearance
For iOS 11.4+ and Xcode 9.4 +
Use this code either in one or all your view controllers
override var prefersStatusBarHidden: Bool {
return true }
Add the following code to your view controller:
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
What helped me is this (changing plist file):
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Put this code to your view controller in which you hide status bar:
- (BOOL)prefersStatusBarHidden {return YES;}
In iOS 7 status bar appearance depends on UIViewController as default. To hide status bar globally, in info.plist use NO value for UIViewControllerBasedStatusBarAppearance key and use UIApplication's setStatusBarHidden method with YES BOOL value.
add this key key from dropdownlist in "info.plist" and voila you will no more see top bar that includes elements something like GSM,wifi icon etc.
It's working for me ,
Add below code into the info.plist file ,
<key>UIStatusBarHidden</key>
<false/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Hopes this is work for some one .
In info.plist
View controller-based status bar appearance NO
Status bar is initially hidden YES
In view controller.m
- (BOOL) prefersStatusBarHidden
{
return YES;
}
I am supporting iOS 5, 6, & 7. My app is iPad only. I needed to use all of the following:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
View Controller:
- (BOOL)prefersStatusBarHidden{ return YES; }
Info.plist
<key>UIStatusBarHidden</key>
<string>YES</string>
<key>UIStatusBarHidden~ipad</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<string>NO</string>
Just check the box on Targets/Summary iPad Deployment Info and you status bar will disappear.
It works on my apps.
I had the same problem, but its an easy fix! Just set
status bar is initially hidden = YES
then add an row by clicking on the plus right after the text status bar is initially hidden, then set the text to
view controller-based status bar appearance
by clicking the arrows, and set it to NO
Hope this helps!
Well the easiest way that I do it is by typing the following into the .m file.
- (BOOL) prefersStatusBarHidden
{
return YES;
}
This should work!
-(void) viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
A complete solution in swift, in your view controller
// you can use your own logic to determine if you need to hide status bar
// I just put a var here for now
var hideStatusBar = false
override func preferStatusBarHidden() -> Bool {
return hideStatus
}
// in other method to manually toggle status bar
func updateUI() {
hideStatusBar = true
// call this method to update status bar
prefersStatusBarHidden()
}
To hide status bar for each individual view controller programmatically, use any of the following two procedures:
Procedure 1:
[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Procedure 2:
-(BOOL)prefersStatusBarHidden {
return YES;
}
To hide status bar for the entire application, we should follow the given below procedure:
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
Click here to view screenshot