我刚刚开始iOS开发,所以对于我的第一个项目,我正在开发一个简单的iOS应用程序来拍照并在屏幕上显示它.
这是我的代码,我在第四行得到错误:
- (IBAction)takePicture:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我收到以下警告:
Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate>' from incompatible type 'todd_learningViewController *const __strong'
Run Code Online (Sandbox Code Playgroud)
我不明白警告信息,不知道如何摆脱警告.
谢谢,
编辑:
我的类头文件如下所示:
@interface todd_learningViewController : UIViewController <UIApplicationDelegate>
- (IBAction)takePicture:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *pictureView;
@end
Run Code Online (Sandbox Code Playgroud)
我应该如何修改它?
Chi*_*Sky 16
使您的类实现UINavigationControllerDelegate,此警告消息将消失.此协议中的所有方法都是可选的,因此您无需修改实现类.
为什么我们必须这样做仍然是我想弄清楚但现在这是解决方案.
| 归档时间: |
|
| 查看次数: |
1892 次 |
| 最近记录: |