加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – iOS相机打开警告

发布时间:2020-12-16 05:35:48 所属栏目:百科 来源:网络整理
导读:我刚开始在iOS开发中,所以在我的第一个项目中,我正在开发一个简单的iOS应用程序来拍摄照片并将其显示在屏幕上. 这是我的代码,它在第四行,我得到错误: - (IBAction)takePicture:(id)sender { UIImagePickerController *imagePicker = [[UIImagePickerControl
我刚开始在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,这个警告消息就会消失.此协议中的所有方法都是可选的,因此您不必修改实现类.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读