delegate:
demo使用场景,我有A,B两个controller,A是root,跳转到B,B的数据输入完返回A且携带数据显示到A。

A.h

#import <UIKit/UIKit.h>
#import "SencondViewController.h" @interface FirstViewController : UIViewController<ResultDelegate> @property (strong, nonatomic) IBOutlet UIButton *delegateBtn; @property (strong, nonatomic) IBOutlet UITextField *result_name; @property (strong, nonatomic) IBOutlet UITextField *result_pass; @property SencondViewController *second; - (IBAction)delegateAction:(id)sender; - (IBAction)observeAction:(id)sender; @end

A.m

#import "FirstViewController.h"
#import "SencondViewController.h" @interface FirstViewController () @end @implementation FirstViewController @synthesize result_name;
@synthesize result_pass; - (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib. } - (IBAction)delegateAction:(id)sender {
self.second = [[SencondViewController alloc]init];
self.second.deleage = self;
[self.navigationController pushViewController:self.second animated:true];
} -(void)result:(NSString *)name pre:(NSString *)pass{
result_name.text = name;
result_pass.text = pass;
} @end

====================================================

B.h

#import <UIKit/UIKit.h>

@protocol ResultDelegate
@required
-(void)result:(NSString *)name pre:(NSString *)pass;
@end @interface SencondViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextField *_name; @property (strong, nonatomic) IBOutlet UITextField *_password; - (IBAction)save:(id)sender; @property (retain, nonatomic) id<ResultDelegate> deleage; @end

B.m

#import "SencondViewController.h"

@interface SencondViewController ()

@end

@implementation SencondViewController

@synthesize _name;
@synthesize _password; - (void)viewDidLoad {
[super viewDidLoad];
} - (IBAction)save:(id)sender { NSString *txtName = [self._name text]; NSString *txtPass = [self._password text]; [self.deleage result:txtName pre:txtPass]; [self.navigationController popViewControllerAnimated:true];
} @end

ios之两个view传值的更多相关文章

  1. ios中两个view动画切换

    @interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain) ...

  2. IOS中两个view的切换

    在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secon ...

  3. 通知模式实现两个textField传值及模态视图——iOS开发

    通知模式实现两个textField传值及模态视图--iOS开发 利用通知模式,实现两个不同界面的textField之间的传值,在界面二输入字符,传值到前一界面的textField. 界面的切换,这里临 ...

  4. 【项目经验】之——Controller向View传值

    我们的ITOO进行了一大部分了,整体上来说还是比较顺利的.昨天进行了一次验收,大体上来说,我们新生这块还是可以的.不仅仅进行了学术上的交流,还进行了需求上的更新.也正是由于这一次,我有了解到了一个新的 ...

  5. ASP.NET MVC Controller向View传值方式总结

    Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...

  6. 详解iOS开发之自定义View

    iOS开发之自定义View是本文要将介绍的内容,iOS SDK中的View是UIView,我们可以很方便的自定义一个View.创建一个 Window-based Application程序,在其中添加 ...

  7. MVC:Controller向View传值方式总结

    Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...

  8. UIButton的两种block传值方式

    UIButton的两种block传值方式 方式1 - 作为属性来传值 BlockView.h 与 BlockView.m // // BlockView.h // Block // // Create ...

  9. IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法

    在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...

随机推荐

  1. KnockoutJs学习笔记(七)

    if binding与visible binding类似.不同之处在于,包含visible binding的元素会在DOM中一直保存,并且该元素相应的data-bind属性会一直保持,visible ...

  2. 3.命名规范《.NET设计规范》

    3.命名规范 3.1 大小写约定 使用合适的大小写增强名字可读性. 3.1.1 标识符的大小写规则 标识符的每个单词首写字幕大写.不要用下划线. PascalCasing camelCasing Pa ...

  3. Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp

    D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...

  4. vue.js阻止事件冒泡和默认事件

    首先我们来看原生JS取消事件冒泡方法: e.stopPropagation(); //非IE浏览器window.event.cancelBubble = true; //IE浏览器 原生JS阻止默认事 ...

  5. django 使用 request 获取浏览器发送的参数

    django 使用 request 获取浏览器发送的参数     转载请注明出处 https://blog.csdn.net/fanlei5458/article/details/80638348 获 ...

  6. 把.html转换成.jsp中jqplot画图表不能正常显示,出错的心得

    在做这个的时候,明明html中是完全可行的,如下图: 但后缀名改成.jsp后竟出现如下情况: 这太坑爹了吧,我的图呢! 哎,又要自己找代码问题了,无奈! 先给出我还没修改前的代码吧,关于里面的.js, ...

  7. bzoj 4004 向量拟阵

    题解RT. eps = 1e-10 WrongAnswer eps = 1e-5 Accepted /************************************************* ...

  8. Codeforces Round #371 (Div. 2) C. Sonya and Queries 水题

    C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learn ...

  9. j.u.c系列(11)---之并发工具类:Exchanger

    写在前面 前面三篇博客分别介绍了CyclicBarrier.CountDownLatch.Semaphore,现在介绍并发工具类中的最后一个Exchange.Exchange是最简单的也是最复杂的,简 ...

  10. oracle 树型结构数据的查询

    Oracle中start by prior子句用法 connect by 是结构化查询中用到的,其基本语法是: select ... from tablename start with 条件1 con ...