AppDelegate.m

 #import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
/**
* 第一步:创建window对象
*/ // 创建window
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible]; /**
* 第二步:设置window的根视图控制器
*/
// 2.1 创建UINavigationController控制器,并指定导航控制器的根视图控制器 // 创建UITabBarController对象
UITabBarController *mainTab = [[UITabBarController alloc] init]; // 将mainTab作为导航控制器的根视图控制器
UINavigationController *rootNav = [[UINavigationController alloc] initWithRootViewController:mainTab]; // 设置控制器数组 FirstViewController *firstVC = [[FirstViewController alloc] init];
firstVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:]; SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:]; ThirdViewController *thirdVC = [[ThirdViewController alloc] init];
thirdVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemHistory tag:]; // 添加到控制器数组中
mainTab.viewControllers = @[firstVC, secondVC, thirdVC]; // 设置window的根控制器
self.window.rootViewController = rootNav; // 一键设置
[UINavigationBar appearance].barTintColor = [UIColor magentaColor]; [UINavigationBar appearance].tintColor = [UIColor whiteColor]; [UITabBar appearance].tintColor = [UIColor purpleColor]; return YES;
} @end

FirstViewController.m

 #import "FirstViewController.h"

 @interface FirstViewController ()

 @end

 @implementation FirstViewController

 - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. // self.title = @"第一页"; // self.tabBarController.navigationItem.title = @"第一页"; // 只走一次 NSLog(@"第一页已加载"); // 在这里写,翻页的话,不会改变,永远留在这个位置,也就是添加统一的左按钮
self.tabBarController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(click:)];
} - (void)viewDidAppear:(BOOL)animated { NSLog(@"第一页出现"); self.tabBarController.navigationItem.title = @"第一页"; // 每次点击这一页,都会加载一次
} - (void)click:(UIBarButtonItem *)sender { NSLog(@"统一的左按钮被点击");
} @end

UITabBarController QQ的更多相关文章

  1. iOS开发——UI进阶篇(十三)UITabBarController简单使用,qq主流框架

    一.UITabBarController简单使用 // 程序加载完毕 - (BOOL)application:(UIApplication *)application didFinishLaunchi ...

  2. swift:用UITabBarController、UINavigationController、模态窗口简单的搭建一个QQ界面

    搭建一个QQ界面其实是一个很简单的实现,需要几种切换视图的控制器组合一起使用,即导航控制器.标签栏控制器.模态窗口.其中,将标签栏控制器设置为window的rootViewController,因为Q ...

  3. [iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理

    A.需求 1.类似QQ.微信顶部或者底部的窗口转换导航条 2.给每个页面添加相应内容   B.UITabBarController 1.基本概念: (1)内容高度 iOS7之前内容高度为:屏幕高度 - ...

  4. 用代码生成UINavigationController 与UITabBarController相结合的简单QQ框架(部分)

    首先我们需要搭建一个空的项目,当然xcode6.0以后不支持直接创建空项目,所以我们需要在系统生成项目之后,删除xcode自动给你生成的控制器和storyboard,另外需要在Main Interfa ...

  5. iOS开发UI篇—UITabBarController简单介绍

    iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...

  6. iOS学习28之UITabBarController

    1. 标签视图控制器 -- UITabBarController 视图(UIView) ---> 图层 ---> 子视图 视图控制器(UIViewController) ---> 管 ...

  7. 标签控制器  UITabBarController

    UITabBarController和UINavigationController类似,UITabBarController也可以轻松地管理多个控制器,轻松完成控制器之间的切换.   #import ...

  8. [BS-09] UITabBarController简单介绍

    iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...

  9. ios基础篇(八)——UITabBarController的简单介绍

    一.简介 UITabBarController和UINavigationController类似,UITabBarController也可以轻松地管理多个控制器,轻松完成控制器之间的切换,典型的例子就 ...

随机推荐

  1. 模拟Jquery选择器

    目前实现的功能有以下几点: 1.$("#adom"); // 返回id为adom的DOM对象 2.$("a"); // 返回一个a标签的数组 3.$(" ...

  2. win7激活

    应亲戚要求,装了次win7系统,重新删除分区,格盘,重新划分好分区.完毕.发现系统分区全自动变成动态磁盘.使用win7激活工具时,注意选择使用 小马通用版激活工具. 动态磁盘 稍后解释 小马工具

  3. http协议客户端向服务器端请求时一般需要发送的内容

    out.println("GET /shopping/index.html HTTP/1.1");//请求行 包括请求方式,文件路径, http协议版本(必写)请求头.... ou ...

  4. Git 分支合并

    理解核心 Git最初只有一个分支,所有后续分支都是直接或间接的从这个分支切出来的. 在任意两个分支上,向前追溯提交记录,都能找到一个最近的提交同时属于这两个分支,这个提交就是两个分支的分叉节点 分支合 ...

  5. mac ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    好久不用mysql,今天突然想用的时候, mysql -uroot -p 直接报了下面的错误 ERROR 2002 (HY000): Can't connect to local MySQL serv ...

  6. [ORM] Entity Framework(2) CodeFirst进阶

    在上一节中,实现了CodeFirst快速入门.但是很多与数据库的细节还无法自定义.以及使用EF过程中,需要注意的事项. 在本节中,会涉及到以下 EF中的连接字符串 EF的对象状态 延迟加载,为什么需要 ...

  7. sprint3 总结

    sprint3 本次的主要任务是找项目中的bug,并与客户不断地沟通以满足客户的要求.队友主要负责找项目中的bug或提出一些建议.我主要是负责与客户沟通和修复bug.总的来说进展还算顺利. 团队贡献分 ...

  8. 基于android平台的斗地主AI

    本软件是基于android平台的斗地主AI,我们在源代码的基础之上,旨在改进AI的算法,使玩家具有更丰富的体验感,让NPC可以更为智能. (一)玩法解析: (1)发牌和叫牌:一副扑克54张,先为每个人 ...

  9. P6 EPPM 16 R1 文档和帮助系统

    P6 EPPM 16 R1 文档和帮助系统 https://docs.oracle.com/cd/E74894_01/ http://docs.oracle.com/cd/E68202_01/clie ...

  10. 比较body.onload(function())、$(document).ready(function())与$(windows).load(function)

    原理对比: body.onload(function())是优先将document的DOM渲染,即将页面所有的元素(包括html标签以及所引用到的图片,flash媒体等媒体文件)加载完成,然后再执行页 ...