ios页面传值的几种方法
2014-12-19 09:58
267 查看
1.属性
2.方法
3.代理方法
4.SharedApplication
5.NSUserdefault
6.通过一个单例的class来传递
属性这种方法传值挺方便的,只需要拿到它的指针,如果重新声明一个指针,就不是原来的内容,不是同一个指针,因此需要传指针。
方法传值这个只要声明要传到那个类的实例变量和方法,就把当前的页面的值传过去。
代理适合从后向前传值。详细参考。
NSUserdefault这个是一个字典,经常用来存储用户名和密码。但是传多次时候有可能覆盖前面的内容。
SharedApplication相当与一个全局变量 [UIApplication UISharedApplication].delegete这个方法还没用过
单例这个也相当与全局的变量
[[UIApplication sharedApplication] delegate];
你可以在AppDelegate里写一个宏:
后面就能用
2.方法
3.代理方法
4.SharedApplication
5.NSUserdefault
6.通过一个单例的class来传递
属性这种方法传值挺方便的,只需要拿到它的指针,如果重新声明一个指针,就不是原来的内容,不是同一个指针,因此需要传指针。
xxxViewController *document = [[xxxViewController alloc] initWithStyle:UITableViewStyleGrouped]; document.docDict = [self.dataArray objectAtIndex:indexPath.row]; document.properties = 要传的值 [self.navigationController pushViewController:document animated:YES]; [document release];
方法传值这个只要声明要传到那个类的实例变量和方法,就把当前的页面的值传过去。
代理适合从后向前传值。详细参考。
NSUserdefault这个是一个字典,经常用来存储用户名和密码。但是传多次时候有可能覆盖前面的内容。
SharedApplication相当与一个全局变量 [UIApplication UISharedApplication].delegete这个方法还没用过
单例这个也相当与全局的变量
[[UIApplication sharedApplication] delegate];
你可以在AppDelegate里写一个宏:
#define APP_DELEGATE ((AppDelegate *)[[UIApplication sharedApplication] delegate])
后面就能用
#import "AppDelegate.h" [APP_DELEGATE.window addSubview:xxxxxx]; FmovieAppDelegate* appDelegate = (FmovieAppDelegate*)[[UIApplication sharedApplication] delegate]; [self.navigationController pushViewController:appDelegate.cinemaViewController animated:YES];
相关文章推荐
- IOS开发之页面间传值的几种小方法
- ios页面传值的几种方法
- asp.net页面传值的几种方法比较
- .NET 页面间传值的几种方法
- asp.net页面传值的几种方法
- 2013、3、11 页面传值的几种方法
- ASP.NET中页面传值的几种方法(很实用)
- asp.net Context.Handler 页面间传值的几种方法
- asp.net页面间传值的几种方法
- ASP.NET 页面间传值的几种方法
- C#页面间传值的几种方法
- ASP.NET中页面传值的几种方法
- 页面间传值的几种方法
- 转:浅析ASP.NET中页面传值的几种方法
- .NET 页面间传值的几种方法
- .net页面间传值的几种常用方法
- asp.net中页面传值的几种经典方法
- ASP.NET中页面传值的几种方法
- 页面、方法-ASP.NET中有几种页面传值方法-by小雨
- .NET 页面间传值的几种方法