简体   繁体   English

**由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'应用程序试图在目标上显示nil模态视图控制器

[英]** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target

Trying to make a camera function to take a photo or choose an exciting photo. 尝试使相机具有拍摄照片或选择令人兴奋的照片的功能。 When I press "Infoga bild"(choose a exciting photo it crashes but when I take a new photo it works. But the image doesn't show in the image view. 当我按“ Infoga bild”(选择一张令人兴奋的照片时,它会崩溃,但是当我拍摄新照片时,它会起作用。但是,该图像不会在图像视图中显示。

Getting the error ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target *** First throw call stack: 收到错误**由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'应用程序试图在目标上显示nil模态视图控制器***首先抛出调用栈:

I open the controller view from a tableview cell. 我从一个tableview单元打开控制器视图。

the code for the camera function: 相机功能的代码:

#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

The .h code: .h代码:

@interface FMEImageview : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
UIImagePickerController *picker;
UIImagePickerController *picker2;
UIImage *image;

IBOutlet UIImageView *ImageView;

}

- (IBAction)Tabild;
- (IBAction)Infogabild;

@end

Thx in advance and i hope my code or question doesn't suck to much. 事先谢谢,我希望我的代码或问题不会太多。 I'm new to objective-c 我是Objective-C的新手

当您在其中创建的控制器名为picker2时,您似乎正在尝试在Infogabild中呈现Picker。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“应用程序试图在目标上显示nil模态视图控制器 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target NSInvalidArgumentException&#39;,原因:“应用程序试图在目标上显示nil模态视图控制器 - NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“数据参数为nil” - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' ***由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“试图弹出到不存在的视图控制器。” - *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Tried to pop to a view controller that doesn't exist.' 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“ *** setObjectForKey:键不能为零” - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil' 由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;UICollectionView必须使用非nil布局参数初始化 - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'UICollectionView must be initialized with a non-nil layout parameter Swift:由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“实体名称不能为零。” - Swift : Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Entity name must not be nil.' 得到“ ***由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;-[__ NSCFNumber compare:]:nil参数&#39;” - getting “*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber compare:]: nil argument'” 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“ *** setObjectForKey:对象不能为nil(键:索引)” - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: index)' 由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;+ entityForName:nil不是合法的NSManagedObjectContext - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM