开发笔记:导航控制器(二)(故事板)push modal custom
来源:互联网 发布:dnf超级技能源码 编辑:程序博客网 时间:2024/05/19 12:27
在苹果公司的官方demo 可以看出 已经更新了用故事板模式 布局UI , 故事板模式给程序员带来了很大的方便,
在页面之间的跳转通过拖拽,也变的非常简单,也更加清晰的看见应用程序是如何布局的,对与其他开发人员维护带来了很大的方便,
废话不多少 直接主题
一 创建导航控制器
拖拽一个视图的导航控制器放在故事板中
然后按住ctrl 键 向你的根视图拖拽过去,这时候我们发现有几个连接的选项 push,modal ,custom , root view controller。
很显然我们应该连接的是 root view controller。 这样我们就创建完了导航控制器!真的很简单。
二 push
push 到下个页面也超级简单!在导航栏上拖拽个buttonitem 按钮 然后点击buttonitem 按住ctrl 拖拽到你想跳转的页面上,连接push。
这样就ok了,so easy吧 。
我们跳转的时候发现 back 还是英文的!
现在我们用鼠标点击下导航栏 我们发现在右边出现了Navigation item 的设置栏
如下图 我们可以设置标题 ,提示 ,返回按钮 。
如果你想发回按钮是自己定制的换个图片貌似没有看见相关的设置 !那也无妨,添加少量代码还是可以的
在第一章我写到的方法 这样就可以改变返回按钮的样式了
UIImage *imge = [UIImageimageNamed:@"导航_返回.png"];
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]initWithImage:imgestyle:UIBarButtonItemStyleDonetarget:selfaction:@selector(pushActions)];
self.navigationItem.leftBarButtonItem = leftButton;
self.view.backgroundColor = [UIColorgreenColor];
三 mode
这个同理也是拖拽过去连接mode 就ok 了返回要用代码
- (IBAction)dicMissAction:(id)sender
{
[self dismissViewControllerAnimated:NOcompletion:nil];
}
点击连接线路中间的圆环在这里我们可以设置mode 的动画效果和 标识符 和 格式
四 custom
同理拖拽,连接custom
然后再创建一个 用来自定义跳转的Segue Class函数
如图 subclass 选择 UIStoryboardSegue
然后,点击连线中间的圆圈 设置标识符 关联上创建的类!
这两样都设置完就要写代码自定义了
代码也是很简单的 在Segue Class函数 里添加头文件和自己定义的代码
你可义在里面定义自己想要的动画!我只是简单写了个push!
#import "CustomViewController.h"
#import "ViewController.h"
@implementation CustomNavigation
-(void)perform
{
ViewController *rootView =self.sourceViewController; //源视图
CustomViewController *coustomViews =self.destinationViewController;//目标视图
[rootView.navigationController pushViewController:coustomViewsanimated:YES];
}
导航控制四种连接方式都说完了!
也顺便说下 传值吧
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSString *name = @"leng";
//topush 为圆环内的标识符
if ([segue.identifier isEqualToString:@"topush"])
{
id destination = segue.destinationViewController;
//theName 为要给赋值那个字符串的名字
[destination setValue:name forKey:@"theName"];
}
}
还有就是我们经常用的tableview 里 didSelectRowAtIndexPath 跳转!但是传值的时候先走的prepareForSegue
说以我们就不能在didSelectRowAtIndexPath 处理数据了,他的执行顺序是
willSelectRowAtIndexPath --> prepareForSegue --> didSelectRowAtIndexPath
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
return indexPath;
}
demo 源码 http://download.csdn.net/detail/lengshengren/6582289
- 开发笔记:导航控制器(二)(故事板)push modal custom
- 【IOS 开发学习总结-OC-55】故事板中 segue 的 push、modal、popover、replace、custom 学习笔记
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- modal一个导航控制器
- [iOS学习]iOS开发中视图相关的小笔记:push、modal、popover、replace、custom
- 开发笔记 导航控制器(一)
- IOS开发学习笔记(导航控制器,视图控制器,模态)
- A 控制器 Push 到 B 控制器 presentViewController(modal模态)到C控制器
- 导航控制器push自定义
- 导航控制器push/pop
- iPhone开发基础教程笔记(九)--第九章 导航控制器和表视图(二)
- iOS --切换控制器方式 push / modal
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- 【iOS开发-21】UINavigationController导航控制器初始化,导航控制器栈的push和pop跳转理解
- PHP教程:PHPUnit学习笔记(六)Fixture
- Linux rpm 命令参数使用详解[介绍和应用]
- 10个步骤让你成为高效的Web开发者
- bootstrap中的page headers 和 hero unit
- IOS下的 NSTimer与Run loop Modes
- 开发笔记:导航控制器(二)(故事板)push modal custom
- remaster ubuntu alternative iso
- tomcat 中指定JDK
- 【Storm总结-1】Storm 简介 -- 转一个我认为总结的比较好的介绍 .
- 《蛙》短评及书摘
- linux配置java环境变量(详细)
- 飞鸽传书整个逻辑盲写,不做测试
- 字符串模式匹配算法——BM、Horspool、Sunday、KMP、KR、AC算法一网打尽
- 音频编码的种类