Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController delegate warning

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!

like image 810
SomaMan Avatar asked Mar 02 '12 09:03

SomaMan


2 Answers

This is duplicate question to iPhone - UIImagePickerControllerDelegate inheritance.

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

like image 155
Zdenek Avatar answered Jan 02 '23 20:01

Zdenek


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

like image 28
Kunal Gupta Avatar answered Jan 02 '23 19:01

Kunal Gupta