I am trying to get answer from this question answer link but failed đ
iOS UIImagePickerController showed blank page
Then I try below code but still show blank screen without image list đ
I think don’t fire the delegation function
You can also check from GitHub
https://github.com/MdAshfaqurRahmanIOS/image-picker-3
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
var imagePicker = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
}
@IBAction func buttonAction(_ sender: UIButton) {
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
present(imagePicker, animated: true)
}
}
extension ViewController: UINavigationControllerDelegate, UIImagePickerControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey(rawValue: "UIImagePickerControllerEditedImage")] as? UIImage {
imageView.image = image
}
picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
}
Add this info.plist
key =>>>> Privacy – Photo Library Usage
value =>> please access photogallery
Console log
- 2020-12-17 22:49:11.928762+0600 image-picker-3[1309:51223]
[lifecycle] [u B37332A2-92E0-4D65-981B-0DBBDB4534D9:m (null)]
[com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin
interrupted while in use. 2020-12-17 22:49:11.944027+0600
image-picker-3[1309:51223] [lifecycle] [u
B37332A2-92E0-4D65-981B-0DBBDB4534D9:m (null)] [com.apple.mobileslideshow.photo-picker(1.0)] Connection to plugin
invalidated while in use. 2020-12-17 22:49:12.003410+0600
image-picker-3[1309:51015] UIImagePickerController UIViewController
create error: Error Domain=NSCocoaErrorDomain Code=4099 "The
connection to service on pid 0 named
com.apple.mobileslideshow.photo-picker.viewservice was interrupted,
but the message was sent over an additional proxy and therefore this
proxy has become invalid." UserInfo={NSDebugDescription=The
connection to service on pid 0 named
com.apple.mobileslideshow.photo-picker.viewservice was interrupted,
but the message was sent over an additional proxy and therefore this
proxy has become invalid.}
2
Answers
You can use it by taking these photos into a collectionView like this "I’ve made it using RxSwift:
}
or you can use it normally:
Try to follow my programmatically example below, first add your button and delegates to your controller and import Photo framework:
now in viewDidLoad add button and set constraints:
After that set your func to present image picker controller:
check the permission, don’t forget to set your info.plist privacy usage description (like you):
write the function to set authorization manually:
this is the result, on dx the alert for manual authorization, on left the picker controller
If you don’t see the preview photos, try to run app with another simulator device.