简体   繁体   中英

Crash when use UIImagePickerController in iOS 13

It work well in the other demo,but crash in my project. I google 'CAMPreviewViewController' but find nothing

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

Assertion failure in -[CAMPreviewViewController _updateIndicatorsForMetadataObjectResults:viewType:viewClass:frameCallback:minimumAreaChangeThreshold:minimumAreaFractionChangeThreshold:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Camera/Camera-3602.9.230/CameraUI/Source/CAMPreviewViewController.m:1152

Try this one

    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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM