今天在帮助群里的一个朋友弄pop事件,在他那边,当前的viewcontroller,不能pop出去。

  初步估计,他的ViewController层级多,他自己没有理清。

  因为pushViewController的时候,是执行栈入的原则,先进后出,后进先出。

  比如A->B->C->D,他这个时候,想popB,但是B的上面还有两个,分别为C和D,C和D没有出来,这个时候,B就没有办法出来。所以,即使执行了pop语句,也达不到pop的效果。

  

  然后中午我自己用storyboard拖了几个东西,简单实现了这个效果,发现自己对storyboard还是不太熟,要仔细实践啊!

  1. 调出storyboard方法:
UIStoryboard * mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

Parameters

name

The name of the storyboard resource file without the filename extension. This method raises an exception if this parameter is nil.

storyboardBundleOrNil

The bundle containing the storyboard file and its related resources. If you specify nil, this method looks in the main bundle of the current application.

Return Value

A storyboard object for the specified file. If no storyboard resource file matching name exists, an exception is thrown with description: Could not find a storyboard named 'XXXXXX' in bundle....

Discussion

Use this method to retrieve the storyboard object containing the view controller graph you want to access. All of the resources associated with the storyboard must be in the bundle indicated by the storyboardBundleOrNil parameter.

  • Name则是自己起的,在.storyboard前面的名字,如果不动,则默认是Main,而且不需要添加文件的扩展名,如果加了,就会报错;
  • bundle:这个参数包含storyboard的文件以及和它相关的资源,如果为空,则会调用当前程序的main bundle

这样,就能拿到程序里面的storyboard了。

  2.调出里面的viewcontroller

  我是在里面直接拖拽了几个viewcontroller,当需要加载这几个viewcontroller的时候,有3件事情要做

    2.1 新建ViewController的.h和.m文件,并且将storyboard里面的nib文件的class,也指向对应的VC;

    2.2 设置Storyboard ID,在Custom Class下面,有一个Identity,这个设置标识符,我们就可以找到它了,像Cell的标识符,一般和头文件名称设置为一样就可以。

    2.3 在代码里面调用它:

UIStoryboard * mainStoryBoard =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
DViewController * dVC = [mainStoryBoard instantiateViewControllerWithIdentifier:@"DViewController"];
[self.navigationController pushViewController:dVC animated:YES];

  这样就可以了。功能就基本实现了。

  

熟能生巧--欢迎大家加入我们的交流群:461093715

最新文章

  1. 一个链接引发的血案---------服务器 IO及网络流量暴涨解决历程
  2. 【转】封装Lua for C#
  3. base64格式的图片如何上传到oss
  4. nopcommerce之权限模块
  5. chrome全局搜索
  6. 命令 tar & zip
  7. mahout算法源码分析之Itembased Collaborative Filtering(二)RowSimilarityJob
  8. ASP.NET MVC验证 - jQuery异步验证
  9. 我的Python成长之路---第八天---Python基础(25)---2016年3月5日(晴)
  10. 坏块管理(Bad Block Management,BBM)
  11. vue获取下拉框值
  12. 干货!Android Studio快捷键VS Eclipse快捷键~亲测!
  13. 动态规划----最长公共子序列(LCS)问题
  14. 用户未登录或Session超时时重定向到登录页,不那么简单
  15. Cisco 12系列 AP 初始化配置-1-安装IOS
  16. python设置路径值时为什么要输入r
  17. 采用spring的schedule注解配置定时任务
  18. 原生JS和JQ窗口定位属性对照表
  19. [Android Pro] ESP和EBP 栈顶指针和栈底指针
  20. Linux防火墙(Firewalls)

热门文章

  1. easyui datagrid 列显示和隐藏
  2. php 上传图片
  3. NBUT 1673 迷宫问题(DP)
  4. 移动Web应用开发入门指南——视觉篇
  5. pycharm 皮肤主题及个性化设置
  6. Bootstrap页面布局19 - BS提示信息
  7. MVC设计模式
  8. 使用Xpath对XML进行模糊查询
  9. php 分词 —— PHPAnalysis无组件分词系统
  10. 【微信开发之问题集锦】redirect_uri 参数错误