Status bar issue in ios 7 [duplicate] - ios

This question already has answers here:
Cannot hide status bar in iOS7
(26 answers)
Closed 8 years ago.
I was trying to hide my status bar in iOS 7 (not in iOS6) and did all the things whatever we need to do for this i.e. In plist,
Status bar is initially hidden=YES
and
View controller-based status bar appearance=NO
and in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I used
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
but it didn't work at all so can anyone diagnose the problem? It may be duplicate question but any other answer didn't help me. One more notable thing here is I used UIImage Picker in my application. Any help will be appreciated!!!

try this code working for me
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:#selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}

Do only three things
[application setStatusBarHidden:YES]; in delegate didFinishLaunchingWithOptions
View controller-based status bar appearance=NO
status bar is initially hidden=YES
I run using this code I am not getting satatusbar visible in ios 7.1

Trying like this can help you, it will compile for iOS7 or greater version.
Add this to your view controller, or if you have some base view controller than add this method there.
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
- (BOOL)prefersStatusBarHidden
{
return YES;
}
#endif

Related

iOS Status bar turned black by Photo Framework

My app uses white status bar text throughout. I've accomplished this through numerous settings below:
1/ In Info.plist I set: View controller-based status bar appearance to "NO"
2/ In - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions I set [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
3/ I implemented the following in the VC I am asking about here:
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
4/ In Storyboard I set the Navigation Bar Style to "Black"
So, a ton of different ways to make sure a simple status bar stays with white text. This is working throughout except for when the users goes to the picture library or the user goes to take a picture. This of course launches Apple's framework which uses a black status bar. That is fine for those controllers as again they are dictated by Apple. However, when the user then cancels or chooses an image and are returned to my controllers, the status bar stays black. I've tried the following when it returns: [self setNeedsStatusBarAppearanceUpdate] but that also does not work.
How can I get the status bar to return to white text after it returns from the Apple controlled photo picker views? I am working with iOS 8 although a check shows that this same problem occurs in 7.1. This happens with both the simulator and real devices.
I found the answer which was to repeat what I did in my step 2 above within the VC that the image picker returns to. So in viewWillAppear I execute: [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; again. Seems like a lot of different ways just to get a status bar to stay white, but now it does under all circumstances.
I guess it will resolve your problem as it resolves mine
Write the code for UIImagePicker and its delegate, add willShowViewController method which is delegate of UINavigationController.
There set the status bar style to LightContent.
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if (([navigationController isKindOfClass:[UIImagePickerController class]] &&
(((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypeCamera)) || (((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypePhotoLibrary))
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
}

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.

Can hide status bar on iphone but ipad when xcode is set to iphone

Ok. I'm going to try to ask this one more time. Hopefully, I will not inadvertently piss off the overflow police. this is not a duplicate question, if you read deeper into the question.
I have an iphone only app that I want to run on iphone and ipad. It runs fine except that when I turn off the status bar it is off on the iphone but not on the ipad.
Any suggestions?
Thanks.
I have set the keys in info.plist
UIStatusBarHidden = YES
and
UIViewControllerBasedStatusBarAppearance = NO
I have included the following code in viewdidload in my starting view controller
- (BOOL)prefersStatusBarHidden {
return YES;
}
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[self prefersStatusBarHidden]; // 10-9 to remove status bar
[self setNeedsStatusBarAppearanceUpdate];
The Info.Plist item should be:
UIViewControllerBasedStatusBarAppearance = YES

Hide status bar in iphone/ipad apps

I'm working on an application for iPhone iPad.
My test iPhone (v4) is on iOS 6.
My test iPad is on iOS 7.
I'd like to remove both statuses bar from the whole application.
Here's what I've tried :
In info.plist, I've set Status bar is initially hidden to YES and View controller based status bar to NO
This didn't work.
So I've set View controller based status bar to YES and in my main view controller I've added :
- (BOOL)prefersStatusBarHidden{
return YES;
}
Though this function never gets called.
In this same controller I've added this to loadview:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
This worked for the iPhone, but the bar still shows up on iPad.
Thanks for your help.
EDIT :
I also have checked "Hide during application launch" in project settings.
EDIT :
Here are two screenshots of my project settings.
http://imgur.com/a/VXZTk
As you can see I've tried the answers of the question you voted this as a duplicate to.
If I'm not doing it wrong, thanks for voting to re-open this question.
You need to have two things to have the status bar hidden throughout whole app in all iOS versions
In info.plist View controller based status bar set to NO . (For iOS 7)
In your applicationDidFinishLaunching add [[UIApplication sharedApplication] setStatusBarHidden:YES]; or simply [app setStatusBarHidden:YES]
Now you can optionally set Status bar is initially hidden to YES also to hide status bar when app launches.
Also if you dont want status bar to be hidden throughout the app.
remove [[UIApplication sharedApplication] setStatusBarHidden:YES]
and override prefersStatusBarHidden in your ViewControllers and return YES or NO
- (BOOL)prefersStatusBarHidden{
return YES;
}
If you set Status bar is initially hidden to YES, it will work fine.
Anyways Have you tried below methods?
-(void)viewDidLoad
{
[super viewDidLoad];
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)])
{
[self prefersStatusBarHidden];
[self setNeedsStatusBarAppearanceUpdate];
}
}
-(BOOL)prefersStatusBarHidden
{
return YES;
}
- (UIViewController *)childViewControllerForStatusBarHidden
{
return nil;
}
Thanks!
Just needed to set deployment infos to universal.
Click xCode project/your target/General/Deployement Info, then check the "hide during application launch"

Staus Bar on launching app ios 6 and 7

In my app i use ios 6 as deployment targer.
i set View controller-based status bar appearance to No in .Plist. status bar,s back ground color change to green as i want on ios 7. but when i run my app on ios 6 it remain black only when launch image is displayed rest is fine to whole app.
i use this code also in my app delegate...
if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
else
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
How to change back ground of status bar background color and text color while launching the app on both ios 6 and ios 7.
1) set the UIViewControllerBasedStatusBarAppearance to YES in the plist
2) in viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
3) add the following method:
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
Because your navigation bar is translucent = YES which is default for iOS 7. Maybe, you also set translucent = YES for iOS 6. Set it to NO for iOS 6 so that it also works on app launch.
In appdelegate.m put.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
return YES;
}

Resources