objective-c – iOS相机打开警告

前端之家收集整理的这篇文章主要介绍了objective-c – iOS相机打开警告前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚开始在iOS开发中,所以在我的第一个项目中,我正在开发一个简单的iOS应用程序来拍摄照片并将其显示在屏幕上.

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

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

我收到以下警告:

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

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

谢谢,

编辑:

我的头文件类似如下:

  1. @interface todd_learningViewController : UIViewController <UIApplicationDelegate>
  2.  
  3. - (IBAction)takePicture:(id)sender;
  4.  
  5. @property (weak,nonatomic) IBOutlet UIImageView *pictureView;
  6.  
  7. @end

我该怎么修改呢?

解决方法

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

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

猜你在找的C&C++相关文章