I suppose this question could be easily classed as a duplicate but can't find answer after searching.
inside cellForRowAt
for my tableView
let chooseProfilePhotoPicker = ChooseProfilePhotoPicker(rootVC: self)
chooseProfilePhotoPicker.cropVC.delegate = self
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(chooseProfilePhotoPicker.iconImageViewTapped(_:)))
cell.iconImageView.addGestureRecognizer(tapGesture)
And the ChooseProfilePhotoPicker
class:
class ChooseProfilePhotoPicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var rootController: UIViewController
init(rootController: UIViewController) {
self.rootController = rootController
}
func iconImageViewTapped(_ recognizer: UITapGestureRecognizer) {
var pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary
rootController.present(myPickerController!, animated: true, completion: nil)
}
}
app crashes when I tap the iconImageView