作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 iPhone 新手,我试图在按下按钮时打开一个 View ,在我的“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
}
我想何时打开此 Controller “SearchViewController”的 View ,并且在 Storyboard 中我为 SearchViewController 的 View 提供了其标识符名称“searchView”但是当我运行时,它给了我以下异常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <ReaderViewController: 0x6864930>.'
有什么帮助吗?提前致谢。
最佳答案
Storyboard中没有标识符为 searchView
的 View Controller ,因此实例化失败并且
instantiateViewControllerWithIdentifier:
方法返回零。仔细检查您的 Storyboard 设置,并注意标识符和名称通常区分大小写,也许您将 View Controller 命名为 SearchView
而不是 searchView
。
也有可能是这样
self.storyboard
它本身没有正确初始化或实例化,因此为零。
编辑:所以您是从代码创建 Storyboard,但实际上不是。解决方案是手动实例化 UIStoryboard。
至于您自己的评论,您最好分配self.storyboard = Storyboard
,否则您将继续收到这些错误...
关于ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : 'Application tried to present a nil modal view controller on target,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11709844/
我是一名优秀的程序员,十分优秀!