在imagePickerController IOS 7中以编程方式删除状态栏

拍照时需要删除状态栏,试试这个但是不行

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

- (IBAction)botonCamara:(id)sender { // Make sure camera is available if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Camera Unavailable" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil]; [alert show]; return; } if (imagePicker == nil) { imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.allowsEditing = YES; } [self presentViewController:imagePicker animated:YES completion:NULL]; } #pragma mark - delegate methods -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; UIImageWriteToSavedPhotosAlbum (image, nil, nil , nil); [self dismissViewControllerAnimated:YES completion:NULL]; } 

如果你想隐藏状态栏完全做到这一点

 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { // iOS 7 [self prefersStatusBarHidden]; [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; } else { // iOS 6 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; } } // Add this Method - (BOOL)prefersStatusBarHidden { return YES; } 

我已经尝试了很多方法,我认为这是以编程方式隐藏状态栏的最简单的方法。

 - (void)showStatusBar { UIWindow *statusBarWindow = [(UIWindow *)[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; CGRect frame = statusBarWindow.frame; frame.origin.y = 0; statusBarWindow.frame = frame; } - (void)hideStatusBar { UIWindow *statusBarWindow = [(UIWindow *)[UIApplication sharedApplication] valueForKey:@"statusBarWindow"]; CGRect frame = statusBarWindow.frame; CGSize statuBarFrameSize = [UIApplication sharedApplication].statusBarFrame.size; frame.origin.y = -statuBarFrameSize.height; statusBarWindow.frame = frame; } 

我的开发环境:Yosemite 10.10.1上的XCode 6.6.1,适用于iOS 8.1

在presentViewController完成块设置状态栏隐藏,并在dismissviewcontroller完成取消隐藏状态栏