UIImagePickerController delegate warning

随声附和 提交于 2019-12-30 06:02:07

问题


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!


回答1:


This is duplicate question to iPhone - UIImagePickerControllerDelegate inheritance.

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




回答2:


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



来源:https://stackoverflow.com/questions/9531216/uiimagepickercontroller-delegate-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!