iOS 7 status bar overlaps camera controls on UIImagePickerController

穿精又带淫゛_ 提交于 2019-11-28 21:59:25

If you want to keep ViewController-Based Status Bar Appearance, subclass UIImagePickerController and override prefersStatusBarHidden and childViewControllerForStatusBarHidden.

@interface NoStatusBarImagePickerController : UIImagePickerController
@end

@implementation NoStatusBarImagePickerController

- (BOOL)prefersStatusBarHidden {
  return YES;
}

- (UIViewController *)childViewControllerForStatusBarHidden {
  return nil;
}

@end

Try this :

- (void)navigationController:(UINavigationController *)navigationController     willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
}

in your appDelegate.

There's an additional setting you need to turn on, starting in iOS 7. In your app's Info.plist, add a line for View controller-based status bar appearance, a Boolean, and set it to NO.

Magurizio

The PsychoDad method works for me. I put the following

[[UIApplication sharedApplication] setStatusBarHidden:YES];

into the method viewWillDisappear of subclass of UIImagePickerController.

But the Alexandru Dranca method is better because in that way the status bar don't appear at all!

However I think this is a BUG of IOS 7...

"View controller-based status bar appearance" set to NO, works for me.

you should leave the

-(BOOL)prefersStatusBarHidden{ 
  return YES;
}

and also add this

-(void)viewWillAppear:(BOOL)animated {
    ...
    [self setNeedsStatusBarAppearanceUpdate];
    ...
}
user1435707

I've been on this bug for repairing ToonPAINT for iOS7 and the thing that finally worked other than setting the two things in the Info.plist file (Status bar is initially hidden = NO; View controller-based status bar appearance = NO)

was to change the style of the status bar (even though I didn't want it shown at all); It was not enough to just hide the status bar; sounds like an iOS7 bug.

In the app delegate add:

-(void)navigationController:(UINavigationController *)navigationController
 willShowViewController:(UIViewController *)viewController
 animated:(BOOL)animated
  {
  [[UIApplication sharedApplication] setStatusBarHidden:YES];
  [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  }

{NB .. UIStatusBarStyleBlackTranslucent is deprecated, probably use UIStatusBarStyleLightContent if trying this}

I think the answer to this question is "This is an iOS 7 bug". None of the methods here helped in our case, and several people have tried to fix this now.

I can't say what steps to reproduce this, but I've seen enough people out there with the same issue, that I think it's safe to say that this is in fact an iOS 7 bug. Most people can fix this problem with the multiple methods listed above. Rarely though, you can't fix it that way. I hope if you are reading this, you are not also one of those people.

This is what worked for me:

@implementation ViewController {
    BOOL hideStatusBar;
}

- (void)showCamera {
    UIImagePickerController *camera = [[UIImagePickerController alloc] init];
    camera.modalPresentationStyle = UIModalPresentationCurrentContext;
    camera.sourceType = UIImagePickerControllerSourceTypeCamera;
    camera.delegate = self;

     hideStatusBar = YES;
    [self setNeedsStatusBarAppearanceUpdate];
    [self presentViewController:camera animated:YES completion:nil];
}

-(BOOL)prefersStatusBarHidden{
    return hideStatusBar;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!