[在iOS 13中使用UIImagePickerController时崩溃

问题描述 投票:0回答:1

在其他演示中效果很好,但是在我的项目中崩溃了。我用google'CAMPreviewViewController'却找不到任何东西

UIImagePickerController * picker=[[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = NO;
picker.delegate = self;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
[self presentViewController:picker animated:YES completion:nil];

CRASH

在-[CAMPreviewViewController _updateIndicatorsForMetadataObjectResults:viewType:viewClass:frameCallback:minimumAreaChangeThreshold:minimumAreaFractionChangeThreshold:]中的断言失败,/ BuildRoot / Library / Caches / com.apple.xbs / Sources / Camera / Camera / Camera-View2.92.9.230 / CameraViewController .m:1152

ios crash uiimagepickercontroller
1个回答
0
投票

尝试此一个

    var imagePicker: UIImagePickerController!

 @IBAction func takePhotoAction(_ sender: UIButton) {
        imagePicker =  UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = .camera
        present(imagePicker, animated: true, completion: nil)
    }

Add This to class as delegates 

 UINavigationControllerDelegate, UIImagePickerControllerDelegate
© www.soinside.com 2019 - 2024. All rights reserved.