0

I was following this tutorial to create a image picker which is accessed from a UITableViewController. However it fails to compile in this line:

imagePicker.delegate = self

With this error:

Cannot assign value of type 'ProfileTableViewController' to type 'protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?'

How do I solve this? My class:

class ProfileTableViewController: UITableViewController,UIGestureRecognizerDelegate,UIImagePickerControllerDelegate {
override func viewDidLoad() {
      imagePicker.delegate = self
}
Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Jacob Smith
  • 803
  • 5
  • 13
  • 23
  • Where is your UINavigationControllerDelegate, you need to inherit it. – Twitter khuong291 Apr 12 '16 at 06:58
  • just add **UINavigationControllerDelegate** after **UIImagePickerControllerDelegate** in your viewcontroller – Nitin Gohel Apr 12 '16 at 06:59
  • This is not the whole code, there are some code to create the UITableView. But what does a UINavigationControllerDelegate looks like? I dont have something like that. – Jacob Smith Apr 12 '16 at 06:59
  • http://stackoverflow.com/questions/29034987/setting-delegate-for-uiimagepicker-returns-error-swift – GenieWanted Apr 12 '16 at 07:00
  • It seems to work but I dont understand why. I didn't needed a UINavigationControllerDelegate before. So why do I need it after implementing image picker? – Jacob Smith Apr 12 '16 at 07:02
  • when you click the button from current viewcontroller to navigate the imageController so we need "UINavigationControllerDelegate" delegate. "UIImagePickerControllerDelegate" which is used to access the selection and failure response through @jacob smit – HariKrishnan.P Jul 14 '16 at 05:50

1 Answers1

0

Implementing a UINavigationControllerDelegate to the class fixed the issue.

Jacob Smith
  • 803
  • 5
  • 13
  • 23