IOS笔记049-UITabBarController
1、简单实现
效果:在视图底部显示一个工具栏

代码实现
// 创建窗口
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
// 指定跟控制器
UITabBarController *tabBar = [[UITabBarController alloc] init];
self.window.rootViewController = tabBar;
UIViewController *vc1 = [[UIViewControlleralloc] init];
[tabBar addChildViewController:vc1];
vc1.view.backgroundColor = [UIColorredColor];
vc1.tabBarItem.title = @"聊天";
vc1.tabBarItem.image = [UIImage imageNamed:@“tab_recent_nor"];
UIViewController *vc2 = [[UIViewControlleralloc] init];
[tabBar addChildViewController:vc2];
vc2.view.backgroundColor = [UIColorgreenColor];
vc2.tabBarItem.title = @"空间";
vc2.tabBarItem.image = [UIImage imageNamed:@“tab_qworld_nor"];
UIViewController *vc3 = [[UIViewControlleralloc] init];
[tabBar addChildViewController:vc3];
vc3.view.backgroundColor = [UIColorgreenColor];
vc3.tabBarItem.title = @"联系人";
vc3.tabBarItem.image = [UIImage imageNamed:@“tab_buddy_nor"];
UIViewController *vc4 = [[UIViewControlleralloc] init];
[tabBar addChildViewController:vc4];
vc4.view.backgroundColor = [UIColorgreenColor];
vc4.tabBarItem.title = @"设置";
vc4.tabBarItem.image = [UIImage imageNamed:@“tab_me_nor"];
vc4.tabBarItem.badgeValue = @“10”; // 右上角显示数字
// 显示窗口
[self.windowmakeKeyAndVisible];
综合使用
UITabBarController的使用
一般是一个UITabBarController控制多个NavigationController,这样可以保证每一个控制器下都有一个单独的顶部导航栏,而不是整个应用只有一个导航栏。
比如下面这个界面,一个UITabBarController控制多个NavigationController,然后有NavigationController控制界面内部的跳转。

类似效果如下:

主界面有三个TableView组成,通过tabBarController进行控制。
在聊天界面选中cell后跳转到下一个控制器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIStoryboard *story = [UIStoryboardstoryboardWithName:@"Main"bundle:nil] ;
SLQChatViewController *chat = [story instantiateViewControllerWithIdentifier:@"chat"];
// 选中cell后跳转到chat界面
[self.navigationControllerpushViewController:chat animated:YES];
}

在设置界面的关于条目通过拖线建立与关于控制器的跳转。

注意情况
主要是各种cell的自定义方法。因为很多界面都是自定义的cell组成的。
还有就是从storyboard中加载控制器进行界面的跳转
UIStoryboard *story = [UIStoryboard storyboardWithName:@“Main"bundle:nil] ;
SLQChatViewController *chat = [story instantiateViewControllerWithIdentifier:@"chat"];
// 选中cell后跳转到chat界面
[self.navigationController pushViewController:chat animated:YES];
隐藏底部导航条可以设置控制的属性

IOS笔记049-UITabBarController的更多相关文章
- iOS 怎么设置 UITabBarController 的第n个item为第一响应者?
iOS 怎么设置 UITabBarController 的第n个item为第一响应者? UITabBarController 里面有个属性:selectedIndex @property(nonato ...
- IOS开发之UITabBarController与UINavigationController混合使用
ios开发中UITabBarController与UINavigationController混合使用是很多app的基础页面结构,下面是简单的的页面初始化的方法,在AppDelegate.m的 - ( ...
- iOS开发之UITabBarController和UICollectionView的使用
这一篇要记录的是iOS开发中UITabBarController控件和UICollectionView控件的使用.APP跑起来之后的效果例如以下图: watermark/2/text/aHR0cDov ...
- 荼菜的iOS笔记--UIView的几个Block动画
前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...
- 【IOS笔记】View Controller Basics
View Controller Basics 视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...
- IOS笔记 1
< ![CDATA[ 笔记 UIWindows 与UIView的关系iOS的坐标系统视图层次结构视图坐标(Frame和Bounds区别)UIView的常用属性和方法坐标系统的变换UIView内容 ...
- UITabBarController 笔记(三) UITabBarController 配合 UINavigationController 的使用
建个空的iOS工程 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictiona ...
- 【转】iOS笔记-自定义控件(OC)
原文网址:http://www.jianshu.com/p/f23862eb7b8a 导读: iOS开发中,很多时候系统提供的控件并不能很好的满足我们的需求,因此,自定义控件便成为搭建UI界面中必不可 ...
- iOS笔记———数据存储
应用沙盒:应用文件系统的根目录,每个应用都有独自的沙盒相互:在xcode中可以用NSHomeDirectory()函数,打印当前应用的沙盒根路径. 应用程序包:包含了所有资源文件和执行文件; * Do ...
- Xamarin开发IOS笔记:切换输入法时输入框被遮住
在进行IOS开发的过程中,出现类似微信朋友圈的交互界面,当用户遇到感兴趣的内容可以进行评论.为了方便评论输入,当出现评论输入框的时候自动将评论输入框移动至键盘的上方,这样方便边输入边查看. 当用户隐藏 ...
随机推荐
- Ubuntu 安装boost 库
使用 apt-get进行安装 sudo apt-get install libboost-dev
- 【C++函数重载】求3个数中最大的数(分别考虑整数、双精度数、长整数的情况)。
#include using namespace std; int main( ) { int max(int a,int b,int c); //函数声明 double max(double a,d ...
- Mono for Android 设计器错误:Disconnected from layout renderer
今早打开vs2012 android 项目的时候出现如下错误提示: 查了半天,终于在官方网站得到答案.(http://forums.xamarin.com/discussion/143 ...
- 跨平台移动开发phonegap/cordova 3.3全系列教程-app启动画面
1.app启动画面设计 用photoshop设计启动画面,图片分辨率为720*1280 保存的文件名为splash.png 将splash.png复制到res\drawable,如图 PS:要先添加闪 ...
- iOS开发 - 在状态栏显示FPS,CPU和内存信息
原理 FPS的计算 CoreAnimation有一个很好用的类CADisplayLink,这个类会在每一帧绘制之前调用,并且可以获取时间戳.于是,我们只要统计出,在1s内的帧数即可. - (void) ...
- 网页编辑器CKEditor4.3.1+CKFinder2.4+JW Player6.7(视频播放器)集成
CKEditor是使用最多的一款在线网页编辑器,不仅好用,而且功能强大.易扩展.浏览器兼容性好.另外,CKEditor网页编辑器经常更新.本程序使用的是最新稳定版CKEditor4.3.1,添加使用了 ...
- VMware-Ubuntu16.04LTS-安装ssh
1,检查是否安装ssh 2,安装ssh
- windows剪切板暂存
其实最初是因为在项目中使用了html网页编辑器,通过ie的com组件和javascript通讯完成一些事情,其中有一个功能是插入表格,我们原本使用的range.pasteHTML(HTMLstr);根 ...
- httpd2.4.6三种工作模式(如何配置),防止占用内存暴增的策略
之前偷懒默认用yum安装了httpd.后来发现服务器内存暴增,一度达到75% 打开一看,好嘛后台休眠进程全是httpd. 重启之后再度访问发现内存还是稳步增长. [root@iz2ze3ayxs2yp ...
- Mybatis-动态 SQL语句
if标签 判断语句,用户单条件分支判断 where标签 为了简化上面where 1=1的条件拼装,我们可以采用标签来简化开发 同 foreach标签 场景:传入多个 id 查询用户信息 标签用于遍历集 ...