Assigning to id<UINavigationControllerDelegate,UIImagePickerControllerDelegate> from incompatible type CameraViewController*警告显示在picker.delegate = self;行附近

-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;

if((UIButton *) sender == takePhoto) {
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
    //picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
   picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}

[self presentModalViewController:picker animated:YES];

}

最佳答案

The documentation for UIImagePickerController 说,委托(delegate)必须实现UIImagePickerControllerDelegate协议(protocol)。您的CameraViewController要么未实现此协议(protocol),要么未在其 header 中声明它已实现此协议(protocol)。

关于objective-c - 从不兼容的类型 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>'分配给 'CameraVIewController*'',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8571783/

10-12 04:41