Добрый вечер,
У меня есть три поля, в которых пользователи могут выбирать изображения со своего телефона. Я пытаюсь разрешить пользователям загружать несколько изображений по одному в каждом поле, вроде как трут или Instagram. Когда я выбираю изображения, по какой-то причине он просто выбирает несколько одинаковых изображений вместо трех отдельных. Есть ли способ выбрать изображения по отдельности?
расширение newPostViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@objc func handleSelectJobImageView() {
let picker = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = true
present(picker, animated: true, completion: nil)
}
@objc func handleSelectJobImageView2() {
let picker2 = UIImagePickerController()
picker2.delegate = self
picker2.allowsEditing = true
present(picker2, animated: true, completion: nil)
}
@objc func handleSelectJobImageView3() {
let picker3 = UIImagePickerController()
picker3.delegate = self
picker3.allowsEditing = true
present(picker3, animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
var selectedImageFromPicker: UIImage?
if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage {
selectedImageFromPicker = editedImage
} else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage {
selectedImageFromPicker = originalImage
if let selectedImage = selectedImageFromPicker{
JobImageView.image = selectedImage
dismiss(animated: true, completion: nil)
}
}
var selectedImageFromPicker2: UIImage?
if let editedImage2 = info["UIImagePickerControllerEditedImage"] as? UIImage {
selectedImageFromPicker2 = editedImage2
} else if let originalImage2 = info["UIImagePickerControllerOriginalImage"] as? UIImage {
selectedImageFromPicker2 = originalImage2
if let selectedImage2 = selectedImageFromPicker2{
JobImageView2.image = selectedImage2
dismiss(animated: true, completion: nil)
}
}
var selectedImageFromPicker3: UIImage?
if let editedImage3 = info["UIImagePickerControllerEditedImage"] as? UIImage {
selectedImageFromPicker3 = editedImage3
} else if let originalImage3 = info["UIImagePickerControllerOriginalImage"] as? UIImage {
selectedImageFromPicker3 = originalImage3
if let selectedImage3 = selectedImageFromPicker3{
JobImageView3.image = selectedImage3
dismiss(animated: true, completion: nil)
}
}
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
print("canceled picker")
dismiss(animated: true, completion: nil)
}
}