UIImagePickerController 委托警告 [英] UIImagePickerController delegate warning

查看:29
本文介绍了UIImagePickerController 委托警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的项目中添加了一个照片选择器,一切正常.唯一的事情是它坚持在我设置委托的地方给我以下警告 -

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

}

感谢您的帮助!

推荐答案

这是对 iPhone - UIImagePickerControllerDelegate 继承的重复问题.

简而言之,除了 UIImagePickerDelegate 之外,您的视图控制器还必须符合 UINavigationControllerDelegate.

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

这篇关于UIImagePickerController 委托警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆