11

I've just put a photo picker into my project, and everything works fine. The only thing is it insists on giving me the following warning where I set the delegate -

Assigning to 'id<UINavigationControllerDelegate,UIImagePickerDelegate>' from incompatible type 'AddTargetViewController *'

I have set up the delegate in the AddTargetViewController.h in the normal way -

@interface AddTargetViewController : UIViewController <UIImagePickerControllerDelegate>

and I can't see anything wrong. As I say, it works fine, and all the delegate methods fire off as they should.

-(void)takePhoto {

    UIImagePickerController *imagePicker = [[[UIImagePickerController alloc] init] autorelease];

    imagePicker.delegate = self; // *** warning on this line ***
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

    [self presentModalViewController:imagePicker animated:YES];

}

Thanks for any help!

SomaMan
  • 4,127
  • 1
  • 34
  • 45

2 Answers2

36

This is duplicate question to iPhone - UIImagePickerControllerDelegate inheritance.

In short your view controller has to conform to UINavigationControllerDelegate in addition to UIImagePickerDelegate.

Community
  • 1
  • 1
Zdenek
  • 3,653
  • 27
  • 34
  • Thanks - you don't know how long I trawled this site for an answer to this, but I missed that one! I don't think it would be hard for Apple to make it a bit clearer, as it's not blindingly obvious (not to me anyway...) – SomaMan Mar 10 '12 at 03:18
3

Along with your UIImagePickerControllerDelegate just add UINavigationControllerDelegate in your .h file and it should work fine.

atinder
  • 2,080
  • 13
  • 15
Kunal Gupta
  • 2,984
  • 31
  • 34