This question already has answers here:
How to hide status bar in UIImagepickercontroller?
(13 answers)
Closed 8 years ago.
How to hide "Status Bar" when appear UIImagepickerController?
Here i using iOS coding and xcode 5.
In a view has two buttons one for camera and another gallery. this view would be showed status bar always.
When user press camera button then will appear camera. but it is showed status bar. After take photo will disappear to view.
I would be like hide "Status Bar" when appear Camera. Is there any code?
**Try this Code :-**
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
//iOS 7 into set this property in info.plist file.
set Status bar is initially hidden = YES
add row: View controller-based status bar appearance = NO
Please try this one :
First set in your .plist file.
'View controller-based status bar appearance' and set to NO.
Add in your AppDelegate Method
[application setStatusBarHidden:NO];
[application setStatusBarStyle:UIStatusBarStyleDefault];
If you want to change statsubar color change the setStatusBarStyle according to your app background color.
Also you can try:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
Solution
Go to your plist file and add a new row, View Controller-Based Status Bar Appearance
This should handle this problem.
put this line in your camera button method
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
you add this code
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
if(IS_IOS_7){
if ([navigationController isKindOfClass:[UIImagePickerController class]] &&
((UIImagePickerController *)navigationController).sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
}
}
Related
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;
}
I have first ViewController with Portrait orientation and second ViewController with landscape orientation. The first ViewController have status bar, the second have not.
Then I present second ViewController from the first ViewController, it presenting with out status bar. Then I dismiss it I go back to first ViewController and have my status bar, but the position of the View is incorrect.
View position like screen have not status bar. How can I update it?
first, try this:
In your landscape VC declare the following:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:true];
// you can also try to hide the status bar with animation:
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationSlide];
}
In your portraint VC declare the following:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:false];
// you can also try to show the status bar with animation:
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationSlide];
}
So I have an app which mainly consists of web views. Everyhting is working fine, I have my status bar and navigation bars configured as I like.
The only issue is, when I go to a website that has a "Choose File" option, it opens the Saved Images to select a image (no issue here), then when I tap on the saved images table cell, the status bar text goes from white to black and I am unable to revert back.
I have tried calling UIStatusBarStyleLightContent in viewDidAppear, viewDidDisappear, etc which solves it reverting, but only on that single view it changes.
Any ideas on how to keep it UIStatusBarStyleLightContent all the time? I should note I have [UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; declared in the App Delegate, and UIViewControllerBasedStatusBarAppearance set to NO.
Thanks.
UPDATE with screenshots:
UPDATE 7/14
I managed to get it somewhat working, but in turn it broke the default video player status bar text. Plus it just won't hide to begin with.
I used:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
-(void) viewDidDisappear:(BOOL)animated {
[self.webView stopLoading];
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
FINAL UPDATE??
Not pretty, but i managed to somewhat get the effect all together between the video player and image uploader.
-(void) viewDidDisappear:(BOOL)animated {
[self.webView stopLoading];
[self.navigationController setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationNone];
}
Set "View controller-based status bar appearanceā to NO in your info.list file;
Add this code
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
to -application:didFinishLaunchingWithOptions: of the AppDelegate.m.
I hope your problem will be solved
I have an iOS 7 app and I have set the status bar text to white in didFinishLaunchingWithOptions as follows:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
I have a webview with a javascript that calls the native Image Picker. In the Image Picker, when I choose a Photo from the Gallery, the status bar text is reset to black.
One way to correct this is to apply the above code again when the Image Picker closes. However, I cannot detect this event since it is on the webview.
Any idea how to fix this?
Try this code in ViewController it works for me
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
I solved it by implementing this:
-(void) viewDidAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[super viewDidAppear:animated];
}
As soon as the Photo Gallery closes, this code is called.
Try with below step.
-> Set the "View controller-based status bar appearance" to "NO" in the plist
And then use
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
there is no instance method to change the color of status bar text. so you have to customize the status bar. you can check this link once..
http://www.appcoda.com/customize-navigation-status-bar-ios-7/
I hid status bar in my app by setting [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; and by this code:
- (BOOL)prefersStatusBarHidden
{
return YES;
}
By when I show the MPMediaPickerController modal with [self presentViewController:mpMediaPlayerController animated:YES completion:^{}];, the status bar is being show again.
How can I hide it?
Subclass the MPMediaPickerController and add:
- (BOOL)prefersStatusBarHidden {
return YES;
}
After getting back from MPMediaPlayerController again hide status bar in ViewWillAppear method
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
Hope it will work.