Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning on iOS camera opening

I am just starting out in iOS development, so for my first project, I'm developing a simple iOS application to take a picture and display it on the screen.

Here's my code, it's on line four that I get the error:

- (IBAction)takePicture:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:YES];
}

I get the following warning:

  Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' from incompatible type 'todd_learningViewController *const __strong'

I don't understand the warning message and don't know how to get rid of the warning.

Thanks,

EDIT:

My header file for the class looks like this:

  @interface todd_learningViewController : UIViewController <UIApplicationDelegate>

  - (IBAction)takePicture:(id)sender;

  @property (weak, nonatomic) IBOutlet UIImageView *pictureView;

  @end

How should I modify it?

like image 790
Todd Davies Avatar asked May 30 '12 09:05

Todd Davies


1 Answers

Make your class implement UINavigationControllerDelegate and this warning message will go away. All the methods in this protocol are optional so you will not have to modify your implementation class.

Why we have to do this is still something I am trying to figure out but for now this is the solution.

like image 107
ChicagoSky Avatar answered Oct 02 '22 20:10

ChicagoSky