Reputation: 21
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
Upvotes: 0
Views: 1052
Reputation:
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
Upvotes: 1