Dan*_*ail 15 iphone uiimagepickercontroller
这有什么问题?我真的不明白UIImagePickerController的一些重要部分....
这里是来源:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
Run Code Online (Sandbox Code Playgroud)
我不能打开照片库吗?任何帮助赞赏!
Ilk*_*aci 10
也许不是在你的情况下,但是当你初始化你的UIImagePickerController对象时,首先你需要在设置任何其他属性之前设置你的源类型,否则你会得到相同的错误.
let imagePickerController = UIImagePickerController()
imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera
imagePickerController.cameraCaptureMode =
UIImagePickerControllerCameraCaptureMode.Photo
imagePickerController.cameraDevice = .Front
imagePickerController.showsCameraControls = true;
imagePickerController.navigationBarHidden = false;
imagePickerController.toolbarHidden = false;
imagePickerController.delegate = self
Run Code Online (Sandbox Code Playgroud)
我的问题是我.front在设置之前将摄像头设备设置为imagePicker.sourceType = .camera,这显然导致崩溃。所以我从更改了我的代码:
imagePicker.cameraDevice = .front
imagePicker.sourceType = .camera
Run Code Online (Sandbox Code Playgroud)
对此:
imagePicker.sourceType = .camera
imagePicker.cameraDevice = .front
Run Code Online (Sandbox Code Playgroud)
和问题解决了:)
我遇到了完全相同的异常,但是我没有使用 UIImagePickerController 控件的实例,而是在 UIWebView 内显示一个网页,该网页具有带有 HTML 媒体访问属性的输入以启用相机访问。
问题在于 UIWebView 似乎无法正确处理 HTML 媒体访问属性。我注意到这些属性的规范随着时间的推移发生了几次变化,因此虽然它看起来像有效的 html 并且适用于设备上的 safari,但它不适用于使用 UIWebView 呈现的页面。
坏的:
<input type="file" accept="image/*" capture="camera" />
Run Code Online (Sandbox Code Playgroud)
好的:
<input type="file" accept="image/*;capture=camera" />
Run Code Online (Sandbox Code Playgroud)
异常立即消失并且拍照有效。这对于 iOS 10 或 11 来说似乎是新的,因为它是现有代码并且过去没有崩溃。
| 归档时间: |
|
| 查看次数: |
9565 次 |
| 最近记录: |