Assigning to id<UINavigationControllerDelegate,UIImagePickerControllerDelegate> from incompatible type CameraViewController*
警告显示在picker.delegate = self;
行附近
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == takePhoto) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
//picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
答案 0 :(得分:83)
请注意,您必须同时遵守UIImagePickerControllerDelegate
和UINavigationControllerDelegate
协议才能使用图片选择器。
答案 1 :(得分:14)
只需添加两种协议。
@interface MyViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
然后显然设置委托。 :)
答案 2 :(得分:8)
The documentation for UIImagePickerController
表示委托必须实施UIImagePickerControllerDelegate
协议。您的CameraViewController
要么没有实现此协议,要么没有声明它在标题中这样做。