iOS 7 status bar overlaps camera controls on UIImagePickerController

前端 未结 9 2354
星月不相逢
星月不相逢 2020-12-15 01:18

I\'ve tried setting the Info.plist \'View controller-based status bar appearance\' to NO, I\'ve tried calling

[[UIApplication sharedApplication] setStatusBar         


        
相关标签:
9条回答
  • 2020-12-15 01:33

    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
    
    0 讨论(0)
  • 2020-12-15 01:42

    Try this :

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

    in your appDelegate.

    0 讨论(0)
  • 2020-12-15 01:43

    you should leave the

    -(BOOL)prefersStatusBarHidden{ 
      return YES;
    }
    

    and also add this

    -(void)viewWillAppear:(BOOL)animated {
        ...
        [self setNeedsStatusBarAppearanceUpdate];
        ...
    }
    
    0 讨论(0)
  • 2020-12-15 01:45

    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.

    0 讨论(0)
  • 2020-12-15 01:48

    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.

    0 讨论(0)
  • 2020-12-15 01:55

    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;
    }
    
    0 讨论(0)
提交回复
热议问题