//
// FirstViewController.h
// 控制器数据传递
//
// Created by wangtouwang on 15/4/15.
// Copyright (c) 2015年 wangtouwang. All rights reserved.
// #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController @end //
// FirstViewController.m
// 控制器数据传递
//
// Created by wangtouwang on 15/4/15.
// Copyright (c) 2015年 wangtouwang. All rights reserved.
// #import "FirstViewController.h"
#import "TwoViewController.h" @interface FirstViewController ()<PropagateDelegate>
{
UILabel *firstLable;
UITextField *firstField;
UIButton *firstBtn;
}
@end @implementation FirstViewController - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor blackColor]]; firstLable = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
firstLable.text=@"第一页面进出值";
firstLable.font=[UIFont systemFontOfSize:15.0];
firstLable.textColor=[UIColor whiteColor];
[self.view addSubview:firstLable]; firstField = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
firstField.textColor=[UIColor blackColor];
firstField.font=[UIFont fontWithName:@"Arial" size:14.0];
firstField.borderStyle=UITextBorderStyleRoundedRect;
firstField.placeholder = @"进出值";
firstField.keyboardType = UIKeyboardTypeDefault;
[self.view addSubview:firstField]; firstBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
firstBtn.backgroundColor=[UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:1.0];
[firstBtn setTitle:@"跳转第二页面" forState:UIControlStateNormal];
[firstBtn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
[firstBtn addTarget:self action:@selector(turnTwoPage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:firstBtn]; } -(void)turnTwoPage:(UIButton *)btn{
TwoViewController *two = [[TwoViewController alloc] init];
two.delegate=self;
[self.navigationController pushViewController:two animated:NO];
} -(void)propagateToValue:(NSString *)result{
NSLog(@"反向传值");
firstField.text=result;
} @end
//
// TwoViewController.h
// 控制器数据传递
//
// Created by wangtouwang on 15/4/15.
// Copyright (c) 2015年 wangtouwang. All rights reserved.
// #import <UIKit/UIKit.h> @protocol PropagateDelegate <NSObject> @required
-(void)propagateToValue:(NSString *)result; @end @interface TwoViewController : UIViewController @property(nonatomic,assign) id<PropagateDelegate> delegate; @end
//
// TwoViewController.m
// 控制器数据传递
//
// Created by wangtouwang on 15/4/15.
// Copyright (c) 2015年 wangtouwang. All rights reserved.
// #import "TwoViewController.h" @interface TwoViewController () @property(nonatomic,strong) UILabel *firstLable;
@property(nonatomic,strong) UITextField *firstField;
@property(nonatomic,strong) UIButton *firstBtn; @end @implementation TwoViewController - (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor blackColor]]; _firstLable = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
_firstLable.text=@"第二页面进出值";
_firstLable.font=[UIFont systemFontOfSize:15.0];
_firstLable.textColor=[UIColor whiteColor];
[self.view addSubview:_firstLable]; _firstField = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
_firstField.textColor=[UIColor blackColor];
_firstField.font=[UIFont fontWithName:@"Arial" size:14.0];
_firstField.borderStyle=UITextBorderStyleRoundedRect;
_firstField.placeholder = @"进出值";
_firstField.keyboardType = UIKeyboardTypeDefault;
[self.view addSubview:_firstField]; _firstBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];
_firstBtn.backgroundColor=[UIColor colorWithRed:/255.0 green:/255.0 blue:/255.0 alpha:1.0];
[_firstBtn setTitle:@"跳转第一页面" forState:UIControlStateNormal];
[_firstBtn.layer setCornerRadius:10.0]; //设置矩形四个圆角半径
[_firstBtn addTarget:self action:@selector(turnFirstPage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_firstBtn];
} //反向传值
-(void)turnFirstPage:(UIButton *)btn{
[self.delegate propagateToValue:_firstField.text];
[self.navigationController popViewControllerAnimated:NO];
} @end

IOS 学习笔记 2015-04-15 控制器数据反向传值的更多相关文章

  1. iOS学习笔记(十一)——JSON数据解析

    在之前的<iOS学习——xml数据解析(九)>介绍了xml数据解析,这一篇简单介绍一下Json数据解析.JSON 即 JavaScript Object Natation,它是一种轻量级的 ...

  2. iOS学习笔记(九)——xml数据解析

    在iPhone开发中,XML的解析有很多选择,iOS SDK提供了NSXMLParser和libxml2两个类库,另外还有很多第三方类库可选,例如TBXML.TouchXML.KissXML.Tiny ...

  3. iOS学习笔记(九)—— xml数据解析

    在iPhone开发中,XML的解析有很多选择,iOS SDK提供了NSXMLParser和libxml2两个类库,另外还有很多第三方类库可选,例如TBXML.TouchXML.KissXML.Tiny ...

  4. IOS学习笔记48--一些常见的IOS知识点+面试题

      IOS学习笔记48--一些常见的IOS知识点+面试题   1.堆和栈什么区别? 答:管理方式:对于栈来讲,是由编译器自动管理,无需我们手工控制:对于堆来说,释放工作由程序员控制,容易产生memor ...

  5. iOS学习笔记-精华整理

    iOS学习笔记总结整理 一.内存管理情况 1- autorelease,当用户的代码在持续运行时,自动释放池是不会被销毁的,这段时间内用户可以安全地使用自动释放的对象.当用户的代码运行告一段 落,开始 ...

  6. iOS回顾笔记(04) -- UIScrollView的基本使用详解

    html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...

  7. iOS学习笔记之UITableViewController&UITableView

    iOS学习笔记之UITableViewController&UITableView 写在前面 上个月末到现在一直都在忙实验室的事情,与导师讨论之后,发现目前在实验室完成的工作还不足以写成毕业论 ...

  8. IOS学习笔记25—HTTP操作之ASIHTTPRequest

    IOS学习笔记25—HTTP操作之ASIHTTPRequest 分类: iOS2012-08-12 10:04 7734人阅读 评论(3) 收藏 举报 iosios5网络wrapper框架新浪微博 A ...

  9. iOS学习笔记总结整理

    来源:http://mobile.51cto.com/iphone-386851_all.htm 学习IOS开发这对于一个初学者来说,是一件非常挠头的事情.其实学习IOS开发无外乎平时的积累与总结.下 ...

随机推荐

  1. PC-破解RAR软件注册问题

    打开RAR文件提示软件注册 压缩软件WinRAR并不是免费软件,用了40天后,每次解压文件时都会弹出一提示,问你是否购买(但不影响功能),下面说下最新版的WinRAR v3.71(现在有更新版了,一样 ...

  2. A Tour of Go Type conversions

    The expression T(v) converts the value v to the type T. Some numeric conversions: var i int = 42 var ...

  3. css3划过图片闪光

    css代码 01 .img { display:block; position: relative; width:800px; height:450px; margin:0 auto;} 02 .im ...

  4. PowerDesigner建数据库模型增加自定义扩展属性

    PowerDesigner自7.x新增加一个特性,就是允许用户通过扩展模型的方式扩展模型的属性,但到底怎用一直搞不清楚.今天和同事商量准备直接在程序的Metadata信息实现上直接使用pdm时,我们需 ...

  5. maven中使用net.sf.json-lib

    <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</art ...

  6. OOP设计模式[JAVA]——02观察者模式

    观察者模式 观察者模式的设计原则 为交互对象之间的松耦合设计而努力,使对象之间的相互依赖降到最低. 观察者模式也是对象行为型模式,其意图为:定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时 ...

  7. CSS-div漂浮

    显示效果如下: 代码如下: <div style="width:100%;border-top:0px solid #999999;"> <div style=& ...

  8. c++虚表的使用 通过虚表调用虚函数的演示代码

    //演示一下c++如何找到虚表地址vptr以及如何通过虚表调用虚函数 //zhangpeng@myhexin.com 20130811 #include <iostream> using ...

  9. 【solr基础教程之九】client

    一.Java Script 1.因为Solr本身能够返回Json格式的结果,而JavaScript对于处理Json数据具有天然的优势,因此使用JavaScript实现Solrclient是一个非常好的 ...

  10. 让Windows Server 2008 + IIS 7+ ASP.NET 支持10万并发请求(转)

    转自:http://www.cnblogs.com/dudu/archive/2009/11/10/1600062.html 今天下午17点左右,博客园博客站点出现这样的错误信息: Error Sum ...