IOS 4.3 hide status bar permanently - ios

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

Related

Can't hide status bar on launch

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

status bar became visible after dismiss UIImagePicker in iOS 8

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.

About statusBar within application

Sorry, I don't know how to expound this issue! Looking at the below image
The front view not show statusBar, but the back view appear within app. Like this, how to achieve? Thanks.
If I understand your question correctly, you want to hide the StatusBar during the Application Launch.
To achieve this you simply have to set a checkbox in your project settings. Click on your Target and click on the checkbox "Hide during Application Launch".
If you really want to hide the StatusBar for a single view you can use in viewWillAppearthe following piece of code:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
And in viewWillDisappearsimply set the value to NO.
You can hide the status bar with:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
You could put that code within the front view controller's viewDidLoad: method:
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//...
}
And you can show it again with:
[[UIApplication sharedApplication] setStatusBarHidden:NO];

Resizing every view to fit again after toggling setStatusBarHidden:YES to setStatusBarHidden:NO

I have a UIView that I want to add to the keyWindow so that it covers everything (including the StatusBar). When I add the view I remove the statusBar using the following piece of code:
[[UIApplication sharedApplication].keyWindow addSubview:aView];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
aView.frame = [[UIApplication sharedApplication].keyWindow bounds];
Everything looks as expected. If I then remove the view and add the statusbar again, everything is fine. However, things go wrong when I rotate my device and then remove the view. The UI is now partially covered by the statusBar (in this case a nav bar). Rotating the device immediately resizes everything so that the UI looks normal again.
How can I ensure the UI (any UI!) is aware of the StatusBar unhiding again so that it adjusts automatically as soon as the UIView is removed from the keyWindow.?
The solution should work, regardless of the type of UI in the App. I happen to use a tab bar and a navigation controller in this particular example, but that doesn't always have to be the case.
I have just solved this problem.
In my situation, it is caused by the order you call the method.And sometimes maybe the animation also have something to do with this.
for example,in my situation:
//call present view controller after call setStatusBarHidden
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[modalPresentedViewController presentModalViewController:self animated:YES];
//call setStatusBarHidden before call the dismiss method.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[modalPresentedViewController presentModalViewController:self animated:YES];
I hope this will help.

I want to hide the bar which shows battery status,Time,Carrirer from application

how to hide the bar from application which shows battery status,Time,Carrier signal? is it status bar or anything else
Yes, that is indeed the statusBar. You can hide it with this line (preferably in applicationDidFinishLaunching:):
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
For the record, if you use setStatusBarHidden:YES you will get:
'setStatusBarHidden:animated:' is deprecated: first deprecated in iOS 3.2
Instead use:
BOOL statusBarHidden = NO;
- (BOOL)prefersStatusBarHidden {
return statusBarHidden;
}
// Hide the status bar.
-(IBAction)foo:(id)sender
{
statusBarHidden = NO;
[self setNeedsStatusBarAppearanceUpdate];
}
Also, you should create the the info.plist item UIViewControllerBasedStatusBarAppearance and set it to YES.

Resources