UINavigationController相关
掌握:
1. UINavigationController的使用:添加、移除控制器。
2. UINavigationBar内容的设置。
---------------------------------------------------------------------------------------------------------
一、控制器的添加和移除:
1. UINavigationController以栈的形式保存子控制器:
@property(nonatomic,copy) NSArray *viewControllers;
@property(nonatomic,readonly) NSArray *childViewControllers;
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
/** 下面方法中用作示意*/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
// 1.创建导航控制器
XZOneViewController *one = [[XZOneViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:one]; // 传入一个栈底控制器来初始化导航控制器 (常用)
// 拿到栈顶控制器(显示在眼前的控制器)
// nav.topViewController
// 存放所有子控制器的栈
// nav.viewControllers
// 这个数组也存放子控制器
// nav.childViewControllers
// 2.添加子控制器
// XZOneViewController *one = [[XZOneViewController alloc] init];
// [nav addChildViewController:one]; // 这样子也能把one控制器放到 数组 viewControllers 和 childViewControllers 中。
// [nav pushViewController:one animated:YES]; // 将one压入栈中,即放入 viewControllers 和 childViewControllers 中。 (推荐用法,有动画)
// nav.viewControllers = @[one]; // 这样也是设置
// nav.viewControllers = @[one]; // 不能这么干,因为viewControllers是只读的。
// 3.设置为窗口的根控制器
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated;
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated;
@property(nonatomic,retain) UIBarButtonItem *backBarButtonItem;
@property(nonatomic,retain) UIView *titleView;
@property(nonatomic,copy) NSString *title;
@property(nonatomic,retain) UIBarButtonItem *leftBarButtonItem;
@property(nonatomic,retain) UIBarButtonItem *rightBarButtonItem;
二、控制器的view结构 以及 UINavigationBar导航条内容的设置:
1. 情景一:
self.navigationItem.title = @"第一个控制器";
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:nil action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:nil action:nil];
self.navigationItem.rightBarButtonItems = @[item1, item2];
self.navigationItem.leftBarButtonItems = @[item1, item2];
2. 情景二:
self.navigationItem.titleView = [UIButton buttonWithType:UIButtonTypeContactAdd];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:nil action:nil];
UINavigationController相关的更多相关文章
- 系统UINavigationController使用相关参考
闲来无事便在网上google&baidu了一番UINavigationController的相关文章,然后又看了下官方文档:看看更新到iOS7之后UINavigationController的 ...
- 嵌入式单片机STM32应用技术(课本)
目录SAIU R20 1 6 第1页第1 章. 初识STM32..................................................................... ...
- UINavigationController与UITabBarController相关问题
UINavigationController与UITabBarController相关问题 UINavigationController与UITabBarController混用是非常常见的,有时候会 ...
- UINavigationController的创建和相关设置---学习笔记四
导航控制器 一.设置字体大小,背景等. 二.自定义返回按钮. 三.设置手势. 一.导航中也有个appearance属性,通过它可以设置所有导航的颜色. 二.自定义返回按钮. 1.首先需要知道的是,要把 ...
- IOS UINavigationController 操作相关集合
1.修改中间Title字体以及大小 [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dict ...
- UINavigationController
知识点: 1)UINavigationController 2)UINavigationBar 3)UINavigationItem 4)UIToolBar ===================== ...
- UIScrollerView遇到UINavigationController
今天在UITabBarController 的第一个Tab 页面中放入一个ScrollView, 原本以为可以正常运行. 结果却让人大跌眼镜. 每当我手动滚动或者 缓慢导航到另外一个页面时,当前的 ...
- 升级到iOS9之后的相关适配
iOS9AdaptationTips(iOS9开发学习交流群:458884057) iOS9适配系列教程[中文在页面下方]转自@iOS程序犭袁 (截至2015年9月26日共有10篇,后续还将持续更新. ...
- iOS开发UINavigation——导航控制器UINavigationController
iOS开发UINavigation系列一——导航栏UINavigtionBar摘要iOS中的导航条可以附着于导航控制器之中使用,也可以在controller中单独使用,这篇博客,主要讨论有关导航栏的使 ...
随机推荐
- vue的组件传输
vue的组件传输有四种,我个人觉得pubsub(订阅/发布)是最好用的,因为他不用去考虑关系,所以我们下面就只讲解pubsub吧 1) 优点: 此方式可实现任意关系组件间通信(数据) 首先我们需要 ...
- maven课程 项目管理利器-maven 1-2maven介绍和环境搭建
maven简介: Maven是基于项目对象模型(POM),通过一小段描述信息来管理项目的构建.报告和文档的软件项目管理工具. 1.1 Maven安装文件夹的结构 bin 目录放置包含mvn的运行脚本 ...
- [学习心得][Introduction to ASP.NET Core 1.0]4-1 Creating a Form
原视频地址https://mva.microsoft.com/en-US/training-courses/introduction-to-asp-net-core-1-0-16841?l=eYlqd ...
- canvas剪辑区域
- 【起航计划 014】2015 起航计划 Android APIDemo的魔鬼步伐 13 App->Activity->Translucent 半透明Activity Theme.Translucent
Activity分类示例的最后几个例子是来显示半透明Activity.例子大同小异.实现Activity的半透明效果主要是通过Style和Theme来实现的. 看看TranslucentActivit ...
- xcode import pod 文件不提示
在使用第三方类库时,使用cocoaPods是非常方便的,具体使用方法可以参考:CocoaPods安装和使用教程 的安装使用方法.今天讨论的问题是,我在使用的时候遇到了一些问题:用cocoaPod si ...
- 轻松解决 Eclipse Indigo 3.7 中文字体偏小,完美 Consolas 微软雅黑混合字体!(转)
在 Windows 7 下初始后化,发现界面变化不大,但中文字体却面目全非,小得根本看不见,而且也看起来很不爽.其实这是 Eclipse 的默认字体换了,以前的一直是 Courier New ,这次e ...
- Chromium源码系列一:Chromium简介及源代码获取和编译
Chromium源码系列一:Chromium简介及源代码获取和编译 Chromium简介 Chromium是一个由Google主导开发的网页浏览器,以BSD许可证等多重自由版权发行并开放源代码.C ...
- ICCV 2017 Best Paper Awards
[ICCV 2017 Best Paper Awards]今年的ICCV不久前公布了Best Paper得主,來自Facebook AI Research的Mask R-CNN[1],與RetineN ...
- Verilog三线 - 八线译码器
参阅了一些书籍和网上的写法,在此Mark. 布尔表达式法 module decode3_8_assign (data_in,data_out,enable);//算法实现 :] data_in; in ...