UI_属性传值
来源:互联网 发布:软件需求管理 编辑:程序博客网 时间:2024/06/03 20:41
RootViewController.m#import "RootViewController.h"#import "SecondViewController.h"@interface RootViewController ()@property(nonatomic, retain)UITextField *myTextField;@property(nonatomic, retain)UILabel *myLabel;@end@implementation RootViewController- (void)dealloc{ [_myTextField release]; [_myLabel release]; [super dealloc];}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. 1.创建一个textField. self.myTextField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 150, 50)]; self.myTextField.layer.borderWidth = 1; self.myTextField.layer.cornerRadius = 10; [self.view addSubview:self.myTextField]; [_myTextField release]; 2.创建label. self.myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 200, 150, 50)]; self.myLabel.layer.borderWidth = 1; self.myLabel.layer.cornerRadius = 10; [self.view addSubview:self.myLabel]; [_myLabel release]; 3.创建一个下一页的button. UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectMake(100, 300, 150, 50); [button setTitle:@"下一页" forState:UIControlStateNormal]; button.layer.borderWidth = 1; button.layer.cornerRadius = 10; [self.view addSubview:button]; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];}- (void)buttonAction:(UIButton *)button { 4.点击下一页,打印textField里的内容. NSLog(@"%@", self.myTextField.text); 5.push下一页. SecondViewController *secondVC = [[SecondViewController alloc] init]; [self.navigationController pushViewController:secondVC animated:YES]; [secondVC release]; // 从前向后进行属性传值. 7.利用属性传值. secondVC.str = self.myTextField.text;}
SecondViewController.h#import <UIKit/UIKit.h>@interface SecondViewController : UIViewController6.先写一条属性.@property(nonatomic, copy)NSString *str;@end
SecondViewController.m#import "SecondViewController.h"#import "RootViewController.h"@interface SecondViewController ()@property(nonatomic, retain)UITextField *textField;@end@implementation SecondViewController- (void)dealloc{ [_textField release]; [super dealloc];}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor whiteColor]; NSLog(@"%@", self.str); self.textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 150, 50)]; self.textField.layer.borderWidth = 1; self.textField.layer.cornerRadius = 10; [self.view addSubview:self.textField]; [_textField release]; 7.在后一个界面中用textField.text来接收这个属性 self.textField.text = self.str; UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectMake(100, 200, 150, 50); [button setTitle:@"返回" forState:UIControlStateNormal]; button.layer.borderWidth = 1; button.layer.cornerRadius = 10; [self.view addSubview:button]; [button addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];}- (void)backAction:(UIButton *)button { 8.返回上一页. [self.navigationController popViewControllerAnimated:YES];}
0 0
- UI_属性传值
- UI_协议传值
- UI_协议传值
- UI_页面传值问题
- UI_界面传值方式
- UI_文本框属性
- UI_组件
- UI_多线程
- UI_协议
- UI_手势
- UI_手势
- UI_霓虹灯
- UI_动画
- UI_通讯录
- UI_数据库
- UI_封装
- UI_手势
- UI_动画-UIView属性动画、block块、仿设变换、CAAnimation
- jQuery之属性过滤选择器
- IllegalStateException: Can not perform this action after onSaveInstanceState
- C#精髓 第四讲 GridView 72般绝技
- JQuery为元素添加样式
- shell编程中的$@和$*的区别
- UI_属性传值
- 关于微赞,微擎,微动力模块安装时出现 版权保护,未在云平台注册 的解决办法
- iOS开发之应用内检测手机锁屏,解锁状态
- CRM-Log4j的使用
- ofbiz的webservice接口提供(1)-WSDL的生成
- ofbiz的webservice接口提供(2)-数据类型的局限性
- Win7下用C#开发windows服务
- Dede基础
- swift基础篇:视图控制器UIViewControler