objective-c – iOS相机打开警告

我刚开始在iOS开发中,所以在我的第一个项目中,我正在开发一个简单的iOS应用程序来拍摄照片并将其显示在屏幕上.

这是我的代码,它在第四行,我得到错误

- (IBAction)takePicture:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;
    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:YES];
}

我收到以下警告:

Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' from incompatible type 'todd_learningViewController *const __strong'

我不明白警告信息,不知道如何摆脱警告.

谢谢,

编辑:

我的头文件类似如下:

@interface todd_learningViewController : UIViewController <UIApplicationDelegate>

  - (IBAction)takePicture:(id)sender;

  @property (weak,nonatomic) IBOutlet UIImageView *pictureView;

  @end

我该怎么修改呢?

解决方法

让你的课程实现UINavigationControllerDelegate,这个警告消息就会消失.此协议中的所有方法都是可选的,因此您不必修改实现类.

为什么我们这样做仍然是我想要弄清楚的东西,但现在这解决方案.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...