【发布时间】:2017-07-12 22:13:06
【问题描述】:
我有一个 UIImagePickerController 在相机模式下工作正常,但在库模式下不行。出现照片库时,您可以滚动并选择取消,但点击时,相册无法选择。一直在尝试解决这个问题大约一个小时,但它不起作用。
XCode 8.3.3 | iOS 10.3.2
添加了所需的适当隐私,下面是我的简单演示代码。
我们将不胜感激。
// Opens Photo Library
func openPhotoLibrary() {
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
let picker = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = true
picker.sourceType = .photoLibrary
present(picker, animated: true, completion: nil)
} else {
UIAlertController.presentWith(title: "Error".localize(), message: "The photo library can not be accessed at this time.".localize(), on: self)
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
dismiss(animated: true, completion: nil)
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
guard currentImage != "left" else {
leftImage = image
leftImageView.image = image
return
}
guard currentImage != "right" else {
rightImage = image
rightImageView.image = image
return
}
guard currentImage != "front" else {
frontImage = image
frontImageView.image = image
return
}
}
问题链接:https://www.youtube.com/watch?v=wsKA994Sg88&feature=youtu.be
【问题讨论】:
-
@dfd 照片库正在打开,但相册的选择没有任何作用。我可以滚动和取消,但不能做任何其他事情。
-
@dfd 照片库正在打开,所以我们知道 if 语句成功。问题是在库中没有任何相册或照片可供选择。
-
@dfd
class PhotoViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { -
@dfd 更新了问题
-
(1)
didFinishPIckingMediaWithInfo被击中了吗? (2) 如果currentImage不是“左”、“右”或“前”,您的代码不会做任何事情。是这样吗?
标签: ios swift uiimagepickercontroller