情景再现

1,自定义一个storyboard:

打开xcode,按下cmd+N,新建一个Storyboard--->next

将新建立的storyboard命名为:TestViewController--->create

在TestViewController.storyboard上加上一个label,其text为:Hello-ios

2,编写UIButton的UIControlEventTouchUpinside事件:

- (IBAction)btnClick:(id)sender {
//创建加载storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"TestViewController" bundle:nil];
//将控制器关联到storyboard
_viewOfStoryboard = [storyboard instantiateInitialViewController];
_viewOfStoryboard.view.backgroundColor = [UIColor whiteColor];
[self dismissViewControllerAnimated:YES completion:nil];
[self presentViewController:_viewOfStoryboard animated:YES completion:nil];
}

运行操作如下:

在加载自定义storyboard界面遇到如下问题

错误原因:应用程序视图向目标展示一个空模式形态的视图控制器,简单的说,storyboard中的视图控制器是空的。

3,解决方案:

  • StackOverflow上给了相关回答(下面是个人的翻译,如有误请指出)

Check the identifier of the viewcontroller, if it is the same that you mentioned in storyboard。

  • 检查viewcontroller上的标识符,确保它在storyboard上是独一无二的。

Make sure that your buddiesOrFacebook is not nil. Set a breakpoint on that line and on the debug area at the bottom see whether the object is not nil. If it is nil then problem lies in the storyboard connection。

  • 确保你的buddies或者facebook(这句话没有理解)不是空的。可以设置断点进行调试,如果该对象是空的,那么就是storyboard的连接出现了问题。

If your current viewcontroller is not launched from storyboard then get storyboard object like this :

如果当前的viewcontroller没有开始加载,可以参考下面的标准写法:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController * buddiesOrFacebook = [storyboard instantiateViewControllerWithIdentifier:@"BuddiesFBFriends"] ;
[self presentViewController:buddiesOrFacebook animated:YES completion:nil];

上面的解决方案并没有解决我的问题,于是采取了第二套解决方案。

打开TestViewController.storyboard视图,操作如下:

选中Is Initial View Controller,确保viewcontroller被初始化。

4,结果:

最后运行正确,如下图:

Application tried to present a nil modal view controller on target “Current View Controller”解决方案的更多相关文章

  1. Android中View绘制优化之三---- 优化View

    本文原创, 转载请注明出处:http://blog.csdn.net/qinjuning 译三: 优化视图 关于如何设计自定义View以及响应触摸时间等,请看Android developer : 地 ...

  2. 键盘弹出后上提view隐藏后下拉view还原并修改scroll过程中旋转屏幕到竖屏view显示错误

    1,注册键盘相应事件 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillSho ...

  3. Asp.Net MVC中Controller、Action、View是如何激活调用的

    上篇我们介绍了MVC的路由,知道在注册路由的时候会创建一个MvcHandler将其和Url规则一起放入到了RouteCollection中,之后请求通过UrlRoutingModule,根据当前的UR ...

  4. ui5 call view or method from another view

    // call view or method from another view //# view call // var view2=sap.ui.jsview("ui5d.popup01 ...

  5. View (五)自定义View的实现方法

    一些接触Android不久的朋友对自定义View都有一丝畏惧感,总感觉这是一个比较高级的技术,但其实自定义View并不复杂,有时候只需要简单几行代码就可以完成了. 如果说要按类型来划分的话,自定义Vi ...

  6. 在Android中将子View的坐标转换为父View的坐标

    在Android中,我们有时候可能会将子View的坐标转换为父View中的坐标.感觉很有用,分享给大家. 在Launcher中有这么一段代码可以完成这项工作.  public float getDes ...

  7. 【转】Android绘制View的过程研究——计算View的大小

    Android绘制View的过程研究——计算View的大小 转自:http://liujianqiao398.blog.163.com/blog/static/18182725720121023218 ...

  8. IOS 7 Study - Manipulating a Navigation Controller’s Array of View

    ProblemYou would like to directly manipulate the array of view controllers associated with aspecific ...

  9. ASP.NET MVC 学习2、从Controller传递数据到View

      参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-view 一,Control ...

随机推荐

  1. Steganography-图片隐写术

    今天做DAM的作业,做到图片水印的时候,想起来当初小调同学把言页之庭的种子通过图片发给我.看到下面这个新闻真是觉得碉堡了!!技术宅又一次可以成功而隐晦的表白了!!哈哈哈!! http://war.16 ...

  2. Sublime Text 3安装与使用

    本文是Sublime Text 全程指引 by Lucida (http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html)的笔 ...

  3. 【LeetCode OJ】Distinct Subsequences

    Problem Link: http://oj.leetcode.com/problems/distinct-subsequences/ A classic problem using Dynamic ...

  4. SQL 金额千分位显示

    第一种:select convert(varchar,cast(_money AS MONEY),1) AS _money -----带小数点的第二种: select reverse(stuff(re ...

  5. uget和aria2

    http://blog.csdn.net/luojiming1990/article/details/9078447 其中的aria2 -v要改成aria2c -v

  6. Python Webk框架学习 Flask

    Flask是一个使用Python编写的轻量级Web应用框架.基于Werkzeug WSGI工具箱和Jinja2 模板引擎. Flask使用BSD授权.Flask也被称为“microframework” ...

  7. Sprint第一个冲刺(第九天)

    一.Sprint介绍 建立云端数据库,把注册的内容保存到云端,不易丢失. 实验截图: 任务进度: 二.Sprint周期 看板: 燃尽图:

  8. [原创]cocos2d-x研习录-第三阶 特性之触屏

    游戏跟视频最大的区别就是互动,而手游(基于智能手机)主要靠触摸屏幕.重力传感和虚拟键盘等方式实现互动.这里主要记录Cocos2D-x对玩家触屏操作的处理. 在Cocos2D-x中触屏分为单点触屏和多点 ...

  9. 几个排序算法的python实现

    几个排序算法     几个排序算法 几个排序算法 冒泡排序 选择排序 插入排序 快速排序 quick sort 冒泡排序 冒泡排序是比较简单的排序方法,它的思路是重复的走过要排序的序列,一次比较两个元 ...

  10. server.transfer 用法

    server.transfer 特点: 1:大家熟悉的一个特点,用server.transfer 跳转到新页面时,浏览器的地址是没有改变的(因为重定向完全在服务器端进行,浏览器根本不知道服务器已经执行 ...