I want to pick images from phone library when I tap on two different UIImageViews and after selection, display them on two different UIImageView's, but I when run the following code, the same image displays at two different UIImageViews, How can I fix it? '''
extension SettingProfileViewController:UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
profilePhoto.image = image
print("profile")
}
if let wallImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
wallpaperPhoto.image = wallImage
print("wallpaper")
}
dismiss(animated: true, completion: nil)
}
}
override func viewDidLoad() {
super.viewDidLoad()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(SettingProfileViewController.handleSelectProfilePhotoView))
profilePhoto.addGestureRecognizer(tapGesture)
profilePhoto.isUserInteractionEnabled = true
let wallTapGesture = UITapGestureRecognizer(target: self, action: #selector(SettingProfileViewController.handleSelectWallpaperImageView))
wallpaperPhoto.addGestureRecognizer(wallTapGesture)
wallpaperPhoto.isUserInteractionEnabled = true
}
@objc func handleSelectProfilePhotoView(){
let pickerController = UIImagePickerController() //открывает галерею
pickerController.delegate = self
present(pickerController, animated: true, completion: nil)
}
@objc func handleSelectWallpaperImageView(){
let pickerCont = UIImagePickerController()
pickerCont.delegate = self
present(pickerCont, animated: true, completion: nil)
}
'''