UINavigationController和Storyboard的应用
来源:互联网 发布:足球竞彩数据分析app 编辑:程序博客网 时间:2024/05/01 22:13
1.新建项目
2.删除项目自带的ViewController和Main.storyboard,并且在target里面General的Main Interface删除Main
3.新建MyTabBarController,继承自UITabBarController
4.新建两个storyboard,命名为AStoryboard和BStoryboard
5.为两个storyboard添加导航
6.新建两个控制器,命名为AViewController和BViewController,继承自UIViewController
7.将故事板即AStoryboard和AViewController绑定以及BStoryboard和BViewController绑定,并且在A故事板上拉一个label,设置text为A,便于切换界面的时候显示,也可设置不同的背景色以便区分A和B故事板
8.在MyTabBarController.m里面写代码将控制器加入tabBar
UINavigationController *naviConA = [[UIStoryboard storyboardWithName:@"AStoryboard" bundle:[NSBundle mainBundle]]instantiateInitialViewController]; naviConA.title = @"A"; [self addChildViewController:naviConA]; UINavigationController *naviConB = [[UIStoryboard storyboardWithName:@"BStoryboard" bundle:[NSBundle mainBundle]] instantiateInitialViewController]; naviConB.title = @"B"; [self addChildViewController:naviConB];
9.在AppDelegate.m写启动
在引入头文件后,写如下启动代码
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; MyTabBarController *myTabBar = [[MyTabBarController alloc]init]; self.window.rootViewController = myTabBar; [self.window makeKeyAndVisible];
10.运行发现项目崩了,错误显示界面
这是因为我忘了在属性面板勾选“ Is Initial View Controller”
11.勾选以后,运行显示效果如下
0 0
- UINavigationController和Storyboard的应用
- UINavigationController+storyboard
- Swift 中UIWebView 和 UINavigationController的应用
- storyboard 和xib的本地化的应用
- 不要在storyBoard和代码中混用UINavigationController
- StoryBoard初探(二):使用UINavigationController和UITabBarController
- 用 storyboard 设置UINavigationController
- storyboard的简单应用
- Storyboard的简单应用
- UINavigationController&storyboard点击返回button时奔溃的问题
- 谈谈iOS 5和Storyboard的应用本地化
- Storyboard的基础应用方法
- storyboard 的一些简单应用
- UINavigationController和UITabBarController的集成
- UITabBarController 和 UINavigationController 的 popToRootViewController
- UINavigationController和scrollview的问题
- 关于StoryBoard的使用(3)两个添加一个UINavigationController||UITabBarController最基本的使用
- 解决在 iOS 8 中用Storyboard modal UINavigationController不能dismiss的问题
- 如何判断Unix系统的一个库文件是32位还是64位的
- 排序算法——选择排序
- java注解及在butternife中的实践和原理
- poj 3608 Bridge Across Islands(旋转卡壳求凸包最短距离)
- Aho-Corasick 多模式匹配算法、AC自动机详解
- UINavigationController和Storyboard的应用
- C语言的字符串(篇章之二)
- 关于获取默认List Title国际化 获取情况
- JPanel面板容器类
- 线程池和数据库连接池的原理
- 重载算术操作符
- LinuxELF文件格式详解--Linux进程的管理与调度(十二)
- http请求返回码
- 第一章 JAVA入门(概述)