在其他演示中效果很好,但是在我的项目中崩溃了。我用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
尝试此一个
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