IOS传值-属性传值
来源:互联网 发布:淘宝店铺品牌怎么申请 编辑:程序博客网 时间:2024/04/28 08:16
属性传值简单方便,但是也有缺点,例如耦合性太高,向多个对象传值不方便。
首先定义两个类,FirstViewController和SecondViewController
在AppDelegate.m文件中
self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:fV];
在第二个页面h文件中#import <UIKit/UIKit.h>
@interface SecondViewController :UIViewController
@property(nonatomic,strong)NSString * str;
@end
在.m文件中
-(void)viewWillAppear:(BOOL)animated{
NSLog(@"%@",self.str);
}
在第一个页面中
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//定义一个按钮
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 100, 100, 100);
button.backgroundColor = [UIColor redColor];
[button addTarget:self action:@selector(doButton) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)doButton{
SecondViewController * seV =[[SecondViewControlleralloc]init];
seV.str =@"传值成功";//属性所要传的值要写在推出下一个窗口前面
[self.navigationControllerpushViewController:seV animated:YES];
}
- IOS传值-属性传值
- IOS传值:属性传值
- IOS 属性传值
- iOS属性传值
- iOS中的属性传值
- iOS 属性传值 Block传值 两个ViewController之间的
- iOS 属性传值失败原因
- IOS--UI之间属性传值
- IOS(UI)_属性传值
- iOS 属性传值失败原因
- iOS 属性传值(正传方式)~demo
- iOS 属性传参
- iOS-OC-iOS传值大全(代理传值,block 传值,单例传值,通知传值,属性传值)
- IOS传值---属性传值、代理委托传值(delegate)传值、单例传值、block传值
- iOS之NSAttributedString属性值
- IOS 页面间传值(属性传值、block传值、代理传值、单例传值、NSNotificaion传值)
- iOS传值(属性传值,代理传值,单例传值,通知传值,Block)
- ios 页面之间的传值:属性传值,代理传值,block传值
- LoadRunner问题汇总
- SEO学习笔记五(SEO实战密码读书笔记)
- 设计模式之十 适配器模式
- STM32串行通信USART讲解笔记
- 学习python(7)冒泡与递归
- IOS传值-属性传值
- asp编程:召开自己的新闻发布会
- 在cmd中使用regasm命令
- 取出一个字节(byte)中的每一位(bit)
- NanoHttpd 专门为嵌入java应用设计的轻型HTTP服务器
- ASP中使用Office2000中的图表控件
- HDU1385 Floyd加正序记录路径
- 线性可分支持向量机
- hadoop源码导入到eclipse后程序报错,sun.net.util.IPAddressUtil这个类找不到与之应的jar包