UITabBarController QQ
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的更多相关文章
- iOS开发——UI进阶篇(十三)UITabBarController简单使用,qq主流框架
一.UITabBarController简单使用 // 程序加载完毕 - (BOOL)application:(UIApplication *)application didFinishLaunchi ...
- swift:用UITabBarController、UINavigationController、模态窗口简单的搭建一个QQ界面
搭建一个QQ界面其实是一个很简单的实现,需要几种切换视图的控制器组合一起使用,即导航控制器.标签栏控制器.模态窗口.其中,将标签栏控制器设置为window的rootViewController,因为Q ...
- [iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理
A.需求 1.类似QQ.微信顶部或者底部的窗口转换导航条 2.给每个页面添加相应内容 B.UITabBarController 1.基本概念: (1)内容高度 iOS7之前内容高度为:屏幕高度 - ...
- 用代码生成UINavigationController 与UITabBarController相结合的简单QQ框架(部分)
首先我们需要搭建一个空的项目,当然xcode6.0以后不支持直接创建空项目,所以我们需要在系统生成项目之后,删除xcode自动给你生成的控制器和storyboard,另外需要在Main Interfa ...
- iOS开发UI篇—UITabBarController简单介绍
iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...
- iOS学习28之UITabBarController
1. 标签视图控制器 -- UITabBarController 视图(UIView) ---> 图层 ---> 子视图 视图控制器(UIViewController) ---> 管 ...
- 标签控制器 UITabBarController
UITabBarController和UINavigationController类似,UITabBarController也可以轻松地管理多个控制器,轻松完成控制器之间的切换. #import ...
- [BS-09] UITabBarController简单介绍
iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...
- ios基础篇(八)——UITabBarController的简单介绍
一.简介 UITabBarController和UINavigationController类似,UITabBarController也可以轻松地管理多个控制器,轻松完成控制器之间的切换,典型的例子就 ...
随机推荐
- JS事件委托的原理和应用
js事件委托也叫事件代理,实际上事件委托就是通过事件冒泡实现的,所谓的事件就是onclick,onmouseover,ondown等等,那么委托呢?委托就是指本来这个事是要你自己做的,但是你却让别人帮 ...
- Unity 坐标系
Unity 使用的是左手坐标系
- VC2013的一个bug
前段时间在尝试使用一个C++的GUI库nana.这个库最大的特点在于使用现代C++风格去编写GUI程序,而不需要使用大量的比较丑陋的代码(如MFC中的各种宏),或者其它的非C++元素.这是一个比较新的 ...
- [JS] JavaScript框架(1) jQuery
jQuery使用户能更方便地处理HTML(标准通用标记语言下的一个应用).events.实现动画效果,并且方便地为网站提供AJAX交互.jQuery还有一个比较大的优势是,它的文档说明很全,而且各种应 ...
- PP66 EEPPPPMM SSyysstteemm AAddmmiinniissttrraattiioonn GGuuiiddee 16 R1
※★◆●PP66 EEPPPPMM SSyysstteemm AAddmmiinniissttrraattiioonn GGuuiiddee 16 R1AApprriill 22001166Conte ...
- Apache log4net™ 手册——概述【翻译】
原文地址 本文内容 概述 框架 日志(Loggers)和追加器(Appenders) 日志层次(Logger hierarchy) 追加器(Appenders) 筛选(Filters) 布局(Layo ...
- Winform开发的界面处理优化
在Winform开发中,客户体验是个很好的参考性指标,如果一个功能使用的时候感觉很流畅,说明我们的程序执行效率还不错,但是随着数据的真多,原先可能流程的地方可能会变得比较卡,这时候就需要追本索源,找到 ...
- (二)Protobuf的C#使用
[转]http://blog.csdn.net/shantsc/article/details/50729402 protobuf c#版本分成两个版本,一个是protobuf-net,另一个是pr ...
- 动态生成RDLC报表
前段时间,做了RDLC报表,主要是三块功能: 1.从DataGrid提取(包括最新的增删改)的数据,自动生成对应的RDLC报表文件(以流的形式驻存在内存中),用ReportViewer类来展示.打印. ...
- 【jQuery基础学习】05 jQuery与Ajax以及序列化
好吧,这章不像上章那么水了,总是炒剩饭也不好. 关于AJAX 所谓Ajax,全名Asynchronous JavaScript and XML.(也就异步的JS和XML) 简单点来讲就是不刷新页面来发 ...