[英]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.