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.
its late but maybe helped someone else
DispatchQueue.main.async {
ImageResult.image = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
}
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.