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中单独使用,这篇博客,主要讨论有关导航栏的使 ...
随机推荐
- DataColumn.Expression提示“...循环引用”的错误
我碰到这个问题的时候,在网上找了找,找到了有好几个提出这个问题的人,但是都没有得到解答,当时很郁闷.然后再看看msdn中的解释与自己的测试,才把这个问题给解决了. 代码如下: person.Colum ...
- The sixteenth day
It is a against the law to drive without a driver's license 翻译: 没有驾照,开车是违法的 注意点: 1.It(连读)is; witout( ...
- (12)JavaScript之[事件][事件监听]
事件 /** * 事件: * onload 和 onunload 事件在用户进入或离开页面时被触发 * * onchange事件常结合对输入字段的验证来使用 * onmouseover 和 onmou ...
- 【QT】【OpenCv】初始配置以及测试功能
#include "mainwindow.h" #include "ui_mainwindow.h" #include<opencv2/core/core ...
- oop编程思想
oop的编程思想:抽象.封装.继承.多态. 1.抽象: 数据抽象:类描述的对象的属性或状态 行为抽象:类描述的对象的行为或功能 举例: 时钟:Class 数据:int Hour,Minute,Seco ...
- git 因线上分支名重复导致无法拉取代码
有时 git pull 或 git fetch 时发现 git 报了个异常,说法像是无法将线上某个分支与本地分支合并,由于分支是...(很长的hash)但是分支却是...(很长的hash) 仔细查查后 ...
- Oracle三种循环例题:打印九九乘法表
数据库SQL三种循环语句(For.While.Loop) --如果要将执行结果输出,需要先执行 setserveroutput on 命令,在窗口里显示服务器输出信息 set serveroutput ...
- 如何在win10中安装ArcGIS10.2
在win10中安装ArcGIS10.2,完美兼容,下面将自己在win10界面下的安装方法给大家分享一下. 工具/原料 win10环境 ArcGIS10.2安装包, 安装包地址链接: 链接: htt ...
- redis hash类型
- Spring boot 实现高吞吐量异步处理(适用于高并发场景)
技术要点 org.springframework.web.context.request.async.DeferredResult<T> 示例如下: 1. 新建Maven项目 asy ...