iOS页面跳转及数据传递
2014-03-18 10:46
381 查看
iOS页面跳转:
第一种
[self.navigationController pushViewController:subTableViewController animated:YES];
//描述:通过 NSNavigationBar 进行跳转
[self.navigationController popViewControllerAnimated:YES];
//描述:在子视图返回到上级视图
第二种
UIViewController *control = [[UIViewController alloc] init];
[self presentModalViewController:control animated:YES];
[control release];
//描述:通过事件进行跳转
[self dismissModalViewControllerAnimated:YES];
//描述:通过事件进行返回。
第三种
[self.view.window addSubview:otherview];
[self.view removeFromSuperview]
数据传递:
1)采用代理模式 子viewcontroller设计 代理协议,定义协议接口,父viewcontroller 实现协议接口,实现子viewcontroller 退出时将相关数据更新到父视图。
2)采用ios的消息机制 父viewcontroller注册消息 子viewcontroller 发送消息,触发父viewcontroller的消息处理。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setData:) name:kNotificationMessage object:nil];//注册监听,其中setData用来处理消息
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationMessage object:self userInfo:infoDict];//发送消息
3)采用database做为数据中间的存储媒介,子viewcontroller将状态数据存入DB,父viewcontroller从DB获取数据更新view。
4)采用ios的NSDefault 存储
5)通过AppDelegate 中定义全局变量实现中间数据的存储。
第一种
[self.navigationController pushViewController:subTableViewController animated:YES];
//描述:通过 NSNavigationBar 进行跳转
[self.navigationController popViewControllerAnimated:YES];
//描述:在子视图返回到上级视图
第二种
UIViewController *control = [[UIViewController alloc] init];
[self presentModalViewController:control animated:YES];
[control release];
//描述:通过事件进行跳转
[self dismissModalViewControllerAnimated:YES];
//描述:通过事件进行返回。
第三种
[self.view.window addSubview:otherview];
[self.view removeFromSuperview]
数据传递:
1)采用代理模式 子viewcontroller设计 代理协议,定义协议接口,父viewcontroller 实现协议接口,实现子viewcontroller 退出时将相关数据更新到父视图。
2)采用ios的消息机制 父viewcontroller注册消息 子viewcontroller 发送消息,触发父viewcontroller的消息处理。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setData:) name:kNotificationMessage object:nil];//注册监听,其中setData用来处理消息
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationMessage object:self userInfo:infoDict];//发送消息
3)采用database做为数据中间的存储媒介,子viewcontroller将状态数据存入DB,父viewcontroller从DB获取数据更新view。
4)采用ios的NSDefault 存储
5)通过AppDelegate 中定义全局变量实现中间数据的存储。
相关文章推荐
- iOS:remove all subviews
- Nagios_监测系统信息
- 几点iOS开发技巧
- ios 人魔七七
- 10个有用的第三方iOS开源库
- Nagios_快速配置
- iOS里的MVC
- 关于iOS7 适配的一些总结
- ios7 下载企业版
- iOS项目的目录结构和开发流程
- iOS开发者有价值的工具集
- 在iOS上使用自签名的SSL证书
- IOS Tableviewcell总结
- ios basic 2.2:working with foundation
- 苹果设备尺寸和控件尺寸
- IOS本地通知
- ios basic 2.1 Using design Patterns
- 旺财iOS版的设计思想
- IOS学习笔记63--截取当前图像保存至相册
- IOS学习笔记:NSFileManager常用方法