objective-c - 从不兼容类型 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' 分配给 'CameraVIewController*' '

标签 objective-c ipad

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];

最佳答案

请注意,您必须同时遵守 UIImagePickerControllerDelegateUINavigationControllerDelegate 协议(protocol)才能使用图像选择器。

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

相关文章:

iphone - 以编程方式在 iPad 中使用图像名称进行屏幕截图

objective-c - MPMoviePlayerController 的字幕

ios - 检查给定的日期时间是否在 Objective C 中的其他两个日期时间之间

TableView 导航栏上的 IOS 按钮不起作用

iphone - 自上次在 iOS 中打开应用程序已有多长时间?

iphone - 检测 UIWebView 是否需要使用 HTTP 或 HTTPS

iphone - 使用 UIbutton 关闭弹出窗口

ios - UICollectionView + SDWebImage + 单元格重用

ios - 将视频写入文件在 iPad 3 上正常工作约 5 秒,然后失败

ios - ipad 上的应用程序双存档大小