Iphone 添加UIImagePickerController时出现警告
我试图添加一个Iphone 添加UIImagePickerController时出现警告,iphone,objective-c,ios,cocoa-touch,Iphone,Objective C,Ios,Cocoa Touch,我试图添加一个UIImagePickerController,我得到一个不兼容类型“id”编译器警告。我想知道为什么?以及解决方案 m h @interface-GobblesViewController:UIViewController { UIImagePickerController*图像选择器; } @属性(非原子,强)UIImagePickerController*imagePicker; 指向[imagePicker setDelegate:self]的警告点我不知道为什么会发生
UIImagePickerController
,我得到一个不兼容类型“id”
编译器警告。我想知道为什么?以及解决方案
m
h
@interface-GobblesViewController:UIViewController
{
UIImagePickerController*图像选择器;
}
@属性(非原子,强)UIImagePickerController*imagePicker;
指向
[imagePicker setDelegate:self]的警告点
我不知道为什么会发生这种情况。您收到此警告是因为在本例中,self
对象表示您正在传递到UIImagePickerController
的委托
属性,不符合UIImagePickerControllerDelegate和UINavigationControllerDelegate协议。这是因为UIImagePickerController
是UINavigationController
的一个子类,它已经声明了自己的委托
UIImagePickerController
上的delegate
属性定义为:
@property (nonatomic, assign) id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;
@interface GobblesViewController : UIViewController <UIImagePickerControllerDelegate>
{
UIImagePickerController *imagePicker;
}
@property (nonatomic,strong)UIImagePickerController *imagePicker;
@property (nonatomic, assign) id <UINavigationControllerDelegate, UIImagePickerControllerDelegate> delegate;
@interface GobblesViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>