简体   繁体   English

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

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

I'm new in iphone, I'm trying to open a view when pressing a button, in my class "ReaderViewController" I wrote the following code: 我是iphone的新手,在尝试按下按钮时打开视图,在我的类“ ReaderViewController”中,我编写了以下代码:

- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)button
{
#ifdef DEBUGX
NSLog(@"%s", __FUNCTION__);
#endif

#if (READER_ENABLE_MAIL == TRUE) // Option

instantiateViewControllerWithIdentifier:@"searchView"];

if (printInteraction != nil) [printInteraction dismissAnimated:NO]; // Dismiss

SearchViewController *searchController = [self.storyboard instantiateViewControllerWithIdentifier:@"searchView"];


searchController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
searchController.modalPresentationStyle = UIModalPresentationFullScreen;

[self presentModalViewController:searchController animated:YES];


[searchController release];


#endif // end of READER_ENABLE_MAIL Option
}

I want when to open the view of this controller "SearchViewController" and in storyboard I gave the view of SearchViewController its identifier name "searchView" but when I run, it gives me the following Exception: 我想要何时打开此控制器“ SearchViewController”的视图,并在情节提要中为SearchViewController的视图赋予其标识符名称“ searchView”,但是当我运行时,它给了我以下异常:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:    'Application tried to present a nil modal view controller on target <ReaderViewController: 0x6864930>.'

Any Help ?? 任何帮助? Thanks in advanced. 提前致谢。

There's no view controller with the identifier searchView in your storyboard, so the instantiation fails and the 故事板上没有标识符为searchView视图控制器,因此实例化失败,并且

instantiateViewControllerWithIdentifier:

method returns nil. 方法返回nil。 Double check your Storyboard setup and also note that identifiers and names are generally case-sensitive, maybe you named your view controller SearchView and not searchView . 仔细检查Storyboard的设置,并注意标识符和名称通常区分大小写,也许您将视图控制器命名为SearchView而不是searchView

It also may be the case that 也可能是这样

self.storyboard

itself isn't properly initialized or instantiated, and thus is nil. 本身未正确初始化或实例化,因此为nil。

Edit : so you were creating the storyboard from code, but in fact you weren't. 编辑 :因此您是通过代码创建情节提要的,但实际上并非如此。 The solution was to manually instantiate UIStoryboard. 解决方案是手动实例化UIStoryboard。

As for your own comment, you'd better assign self.storyboard = Storyboard or you'll continue getting these errors... 至于您自己的评论,最好分配self.storyboard = Storyboard否则您将继续遇到这些错误...

It looks to me like self.storyboard is nil . 在我看来就像self.storyboard nil This means every message you are passing to it results in nil also. 这意味着您传递给它的每条消息也会产生nil

暂无
暂无

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

相关问题 **由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;应用程序试图在目标上显示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