OStack程序员社区-中国程序员成长平台

标题: ios - 在 imagePickerController IOS 7 中以编程方式删除状态栏 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:08
标题: ios - 在 imagePickerController IOS 7 中以编程方式删除状态栏

我需要在拍照时删除状态栏你试试这个但不起作用

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

- (IBAction)botonCamaraid)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)imagePickerControllerUIImagePickerController *)picker didFinishPickingMediaWithInfoNSDictionary *)info
{

    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    UIImageWriteToSavedPhotosAlbum (image, nil, nil , nil);

    [self dismissViewControllerAnimated:YES completion:NULL];
}



Best Answer-推荐答案


如果您想完全隐藏状态栏,请执行此操作

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    if ([self respondsToSelectorselector(setNeedsStatusBarAppearanceUpdate)]) {
        // iOS 7
        [self prefersStatusBarHidden];
        [self performSelectorselector(setNeedsStatusBarAppearanceUpdate)];
    } else {
        // iOS 6
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    }
}

// Add this Method
- (BOOL)prefersStatusBarHidden
{
    return YES;
}

关于ios - 在 imagePickerController IOS 7 中以编程方式删除状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21413294/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4