问题描述
我刚刚在项目中放入了一个照片选择器,一切正常。唯一的事情是它坚持要在设置委托人时给我以下警告-
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 *'
我已经在AddTargetViewController.h中设置了委托正常方式-
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];
}
感谢您的帮助!
推荐答案
这是。
简而言之,除了<$ c之外,您的视图控制器还必须符合 UINavigationControllerDelegate
$ c> UIImagePickerDelegate 。
In short your view controller has to conform to UINavigationControllerDelegate
in addition to UIImagePickerDelegate
.
这篇关于UIImagePickerController委托警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!