Swift 5 imagePickerController 不显示相机图像
相机显示问题
大家好,
我是 Swift 新手,所以请耐心等待我尝试解释我的问题。
我正在 XCode 13 中编写一个应用程序,该应用程序应该拍摄照片并将其显示在名为“ImageResult”的 UIImageView 中。
以下两个函数执行所需的任务:
// Calls Camera (Works)
@objc private func TakePhoto(_ sender: Any) {
let picker = UIImagePickerController( )
picker.sourceType = .camera
picker.allowsEditing = true
picker.delegate = self
present(picker, 动画:正确)
}
// 显示来自相机的图像(不起作用)
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
ImageResult.image = info[UIImagePickerController.InfoKey.editedImage] 为? UIImage
picker.dismiss(animated: true, succession: nil)
}
我遇到的问题是 imagePickerController 在照片后不显示相机图像被采取。 info.plist 已更新为具有所有正确的权限,我什至将源更改为 picker.sourceType = .photoLibrary ,它实际上显示了图像。
不确定其他人是否遇到过这个问题并知道答案,但我真的很感谢任何回应,甚至是建议,因为我觉得我已经用尽了所有途径。预先感谢您的任何帮助。
马蒂。
camera display problem
Hi all,
I am new to Swift so please bear with my as I try to explain my problem.
I am writing an App in XCode 13 that is supposed to take a photo and display it in a UIImageView simply named "ImageResult".
The following two functions perform the required tasks:
// Calls Camera (Works)
@objc private func TakePhoto(_ sender: Any) {
let picker = UIImagePickerController()
picker.sourceType = .camera
picker.allowsEditing = true
picker.delegate = self
present(picker, animated: true)
}
// Display Image From Camera (Doesn't work)
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
ImageResult.image = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
picker.dismiss(animated: true, completion: nil)
}
The problem I am experiencing is that the imagePickerController does not display the camera image after the photo is taken. The info.plist has been updated with all the correct permissions and I have even gone to the extent of changing the source to picker.sourceType = .photoLibrary which does actually display the image.
Not sure if anyone else has experienced this problem and knows the answer but I really appreciate any response even suggestions as I feel as though I have exhausted all avenues. Thanks in advance for any help.
Matty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已经晚了但也许帮助了别人
its late but maybe helped someone else