Status bar appears again after showing MPMediaPickerController modal - ios

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.

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

iOS: StatusBar appearance error

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

Status bar text color changing

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

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

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