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. C# 解析百度天气数据,Rss解析百度新闻以及根据IP获取所在城市

    百度天气 接口地址:http://api.map.baidu.com/telematics/v3/weather?location=上海&output=json&ak=hXWAgbsC ...

  2. imagepng或imagejpeg浏览器无显示问题

    可以先参考这篇文章,检查一下php的文件编码是否有bom 然而我并不是这个问题,后来想到或许是输出缓冲中有其它内容, 于是尝试 ob_clean();$imagepng($im);或//imagejp ...

  3. 【解析 . PPT版】干货:阿里全息大数据构建与应用(包括:互联网金融、互联网+、精准营销...)

    作者:毛波,阿里巴巴资深数据专家,阿里数据管理平台(DMP)产品负责人. 摘要: 回顾传统数据仓库.商业智能到大型分布式数据平台的进化历程,深入阐述阿里的数据发展历史和数据观,以阿里DMP平台为例深入 ...

  4. GET方法传递中文参数乱码解决办法

    1.在页面中对你的URL进行编码 使用------encodeURI(你要使用的中文参数值)如:...?username"+encodeURI(“小甜甜") 2.在后台通过解码来接 ...

  5. 玩转PowerShell第三节——【SCOM Maintenance Mode】-技术&分享

    概述 Microsoft System Center Operations Manager 2007 sp1(SCOM)是微软推出的专业系统监控软件,可以监控部署在网络中的服务器.应用系统和客户端,提 ...

  6. Hadoop入门进阶课程11--Sqoop介绍、安装与操作

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,博主为石山园,博客地址为 http://www.cnblogs.com/shishanyuan  ...

  7. 自动化基础普及之selenium是啥?

    Selenium 并不像QTP那样让人一下子就明白是什么?它是编程人员的最爱,但它却对测试新手产生了很大的阻碍. Selenium 是啥? Selenium RC是啥? Webdriver 又是啥? ...

  8. [git]修改commit

    git commit --amend 修改上一个的commit信息. git reset commit_id 修改commit,同时改变commit历史,可用于合并commit. git revert ...

  9. [编辑器]走上atom之路1

    祝大家新年快乐 我就是来卖个萌,逃- 正文 我最开始用atom是因为它看起来比较酷,我工作中主力还是使用pycharm,毕竟atom只是一个编辑器.我一 般只是用atom来写Markdown的文件.随 ...

  10. 《构建之法》第8、9、10章 读书笔记和Sprint总结

    第八章:需求分析 这章主要解析了需求的多面方面,不同的项目需要不同的手段,真正的需求稍纵即逝,需要靠火眼金睛和敏捷的身手来发现并抓住它们.另外,很多时候用户并不知道自己确切的需求,或者不愿意表达完整的 ...