setStatusBarHidden not working - ios

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:

Related

Unable to hide statusbar in single UIViewController

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;
}

How to change Ios Simulator Network symbol and Time and Charger indicator colors

Hi i am new for ios and in my viewController i have hidden NavigationBar
here i want to change simulator Network symbol and Time and Charger indicator colors in my app
please help how can we do this
i tried some code but not working
code:-
- (void)viewDidLoad {
[super viewDidLoad];
UINavigationBar *navigationBar = [UINavigationBar appearance];
navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBarHidden = YES;
}
Step 1:
Open the info.plist file of your app and set the UIViewControllerBasedStatusBarAppearance to NO
Step 2: Next, in your AppDelegate.m, add this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
Choice-2
First, Go to Project -> Target,
Then set Status Bar Style to Light
and then set View controller-based status bar appearance equal to NO in Info.plist.

How do I hide the status bar of a pushed view controller in objective c?

I have a signup form that pops up when a button is tapped.
My aim is to hide the status bar when this modal is popped up.
Here is my code:
- (IBAction)tappedJoinButton:(id)sender {
if (![PFUser currentUser]) {
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate
// Present the sign up view controller
[self presentViewController:signUpViewController animated:YES completion:NULL];
}
}
I have set View controller-based status bar appearance to yes in my plist file. Now I'd like to choose where I hide the status bar. In this situation I'd like to hide it in the signUpViewController that pops up.
I haven't seen any answers on here showing how to hide it in a pushed view controller.
How do I achieve this?
Kind regards
If you want to hide status bar for only one ViewController the do this:
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (void)viewWillDisappear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[super viewWillDisappear:animated];
}
For your case it will be in PFSignUpViewController.
Hope this helps .. :)
Try this code
in viewDidload of PFSignUpViewController
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
paste this function in controller
- (BOOL)prefersStatusBarHidden {
return YES;
}
you lust like ....
if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
{
[[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
}
Write this in your viewWillAppear...
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Or try This method ....
-(void)navigationController:(UINavigationController *)
navigationController willShowViewController:(UIViewController *)
viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
Add this "View controller-based status bar" appearance in the plist and set NO
[[UIApplication sharedApplication] setStatusBarHidden:YES];

hide status bar iPad iOS 7.0

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;
}

Hiding navigation bar/status bar/prompt

For the life of me, I cannot figure out how to get rid of the white bar at the top of my app.
http://cl.ly/image/3Z2I1x0H3H17
I am currently using a navigation controller as the root view. I've also tried just having a UIViewController as the root view.
In the first UIViewController I have tried:
- (void)viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:YES animated:NO];
}
This does nothing.
I have also tried:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Which hides the status icons (battery, cell connection indicator).
But really, I just want all that white space gone.
Try:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Or set Status Bar to 'None' in the XIB.
In viewDidLoad add this code:
//checks if device is running iOS 7 (or newer) or iOS 6 (or older)
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
Then add this method:
- (BOOL)prefersStatusBarHidden {
return YES;
}

Resources