Maintain a status bar on a UIImagepickercontroller Camera view in iOS 7 and iOS 8

im using UIImagepickercontroller to take photos and select existing photos, when the camera view is displayed, the top on the camera was covered with a white status bar. How can I remove the status bar or hide the status bar. Many of them talk about their ios 7 bug, it is fixed in ios 7.1, but still I ran into this problem.

This is my code to show the imagepickerController

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = (id)self;
imagePicker.sourceType = (buttonIndex == actionSheet.firstOtherButtonIndex ?  

UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary);
[self.viewController presentViewController:imagePicker animated:YES completion:nil]; 


Also I tried with below codes to hide status bar

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



 -(BOOL) prefersStatusBarHidden {
   return YES;


And this is in the delet

 [UIApplication ShareApplication]SetStatusbarHidden:YES];


I am currently working with ios8 and this happens in all versions of ios. Please help me.


source to share

1 answer

Actually the problem is in my rootview controller I am creating a Statusbar using UIView and setting its limits for landscape and portrait programming

- (void)setTopBar {
if(topBar == nil && [[UIApplication sharedApplication] keyWindow] != nil) {
    topBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
    topBar.backgroundColor = navController.view.backgroundColor;
    topBar.tag = topBarViewTag;
    UIView *containerView = [[UIApplication sharedApplication] keyWindow];
    [containerView addSubview:topBar];
    [containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view(20)]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil   views:@{@"view" : topBar}]];
    [containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[view]|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil   views:@{@"view" : topBar}]];
    [containerView layoutSubviews];



so when I commented out the above method in ViewwillAppear, the status bar where not showing, so the problem is with my code.

if anyone is facing the same problem, I suggest you take a look at your RootViewcontroller which navigates to all other classes.



All Articles