尝试使相机功能拍照或选择令人兴奋的照片。当我按下" Infoga bild"(选择一张令人兴奋的照片时它会崩溃但是当我拍摄一张新照片时它会起作用。但是图像在图像视图中没有显示。
获取错误**由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:'应用程序尝试在目标上显示nil模式视图控制器 ***首先抛出调用堆栈:
我从tableview单元格打开控制器视图。
相机功能的代码:
#import "FMEImageview.h"
@implementation FMEImageview
- (IBAction)Tabild {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completion:nil];
}
- (IBAction)Infogabild{
picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
[picker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:picker animated:YES completion:nil];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[ImageView setImage: image];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void) viewDidLoad {
[super viewDidLoad];
}
-(void) didReceiveMemoryWarning{
[super didReceiveMemoryWarning];
}
@end
.h代码:
@interface FMEImageview : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
UIImagePickerController *picker;
UIImagePickerController *picker2;
UIImage *image;
IBOutlet UIImageView *ImageView;
}
- (IBAction)Tabild;
- (IBAction)Infogabild;
@end
提前谢谢,我希望我的代码或问题不会太多。我是objective-c 的新手
答案 0 :(得分:2)
当您在那里创建的控制器名为picker2时,您似乎正在尝试在Infogabild中呈现选择器。