#import "Rigester_ViewController.h"

#import "Rigester_ViewController.h"

@interface Rigester_ViewController ()

@end

@implementation Rigester_ViewController

*

正向传值能够用属性

反向传值代理Block

代理:又叫托付
自己不能办得事托付给别人去干

UIAlertView,UITextField 都使用了代理

写代理的步骤:

// 须要代理,托付的人

1.声明代理里面的协议方法(@protocol)

2.声明协议的属性

3.什么时候须要触发这个代理方法

4.通过协议的属性调用代理方法(托付)

// 代理者。被托付的人须要做的事

5.导入协议

6.在初始化有代理方法的对象的地方
挂上代理(代理者响应代理)

7.写上代理方法
等待被运行

*/

- (void)viewDidLoad {

[super viewDidLoad];

self.title = _titleName;

UIButton *rigesterButton = [UIButton buttonWithType:UIButtonTypeCustom];

rigesterButton.frame = CGRectMake(150, 550, 100, 50);

[self.view addSubview:rigesterButton];

rigesterButton.backgroundColor = [UIColor orangeColor];

rigesterButton.showsTouchWhenHighlighted = YES;

rigesterButton.layer.cornerRadius = 10;

[rigesterButton setTitle:@"注冊" forState:UIControlStateNormal];

[rigesterButton addTarget:self action:@selector(toRigester) forControlEvents:UIControlEventTouchUpInside ];

}

//什么时候触发这个代理方法

- (void)toRigester

{

[self.navigationController popViewControllerAnimated:YES];

//    4.通过协议的属性调用代理的方法

[self.delegate toLoginWithName:@"JZQ"];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

/*

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

*/

@end


@interface Rigester_ViewController ()

@end

@implementation Rigester_ViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.title = _titleName;

UIButton *rigesterButton = [UIButton buttonWithType:UIButtonTypeCustom];

rigesterButton.frame = CGRectMake(150, 550, 100, 50);

[self.view addSubview:rigesterButton];

rigesterButton.backgroundColor = [UIColor orangeColor];

rigesterButton.showsTouchWhenHighlighted = YES;

rigesterButton.layer.cornerRadius = 10;

[rigesterButton setTitle:@"注冊" forState:UIControlStateNormal];

[rigesterButton addTarget:self action:@selector(toRigester) forControlEvents:UIControlEventTouchUpInside ];

}

//什么时候触发这个代理方法

- (void)toRigester

{

[self.navigationController popViewControllerAnimated:YES];

//    4.通过协议的属性调用代理的方法

[self.delegate toLoginWithName:@"JZQ"];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

/*

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

*/

@end


iOS-代理托付的使用的更多相关文章

  1. QF——iOS代理模式

    iOS的代理模式: A要完成某个功能,它可以自己完成,但有时出于一些原因,不方便自己完成.这时A可以委托B来帮其完成此功能,即由B代理完成.但是这个功能不是让B随随便便任其完成.此时,会有一个协议文件 ...

  2. iOS代理模式

    iOS代理模式的简单理解:当一个对象无法直接获取到另一个对象的指针,又希望对那个变量进行一些操作时,可以使用代理模式. 代理主要由三部分组成: (1)协议:用来指定代理双方可以做什么,必须做什么. ( ...

  3. 你真的了解iOS代理设计模式吗?

    在项目中我们经常会用到代理的设计模式,这是iOS中一种消息传递的方式,也可以通过这种方式来传递一些参数.这篇文章会涵盖代理的使用技巧和原理,以及代理的内存管理等方面的知识.我会通过这些方面的知识,带大 ...

  4. iOS 代理反向传值

    在上篇博客 iOS代理协议 中,侧重解析了委托代理协议的概念等,本文将侧重于它们在开发中的应用. 假如我们有一个需求如下:界面A上面有一个button.一个label.从界面A跳转到界面B,在界面B的 ...

  5. 【转】你真的了解iOS代理设计模式吗?

    转自:http://www.cocoachina.com/ios/20160317/15696.html 在项目中我们经常会用到代理的设计模式,这是iOS中一种消息传递的方式,也可以通过这种方式来传递 ...

  6. IOS 代理的简单实现

    原文 http://www.cnblogs.com/lovekarri/archive/2012/03/04/2379197.html 昨天做了一个demo,用到了简单代理. delegate是ios ...

  7. iOS代理模式(delegate)的使用

    前言: 代理模式是iOS中非常重要的一个模式,iOS SDK中的系统控件几乎都用到了代理模式.代理模式用来处理事件监听.参数传递功能. 协议创建(Protocol): 可手打如下代码,或者在代码块里面 ...

  8. iOS 代理 重定向消息 forwardInvocation

    今天简单研究一下iOS的重定向消息forwardInvocation: 首先看看Invocation类: @interface NSInvocation : NSObject { @private _ ...

  9. iOS 代理设计模式

    在项目中经常会用到代理的设计模式,这是iOS中一种消息传递的方式,也可以通过这种方式传递一些参数. 在项目中,刚开始我是用一些代理来传递参数的,但是慢慢觉得代理的代码比较block多,所以就更多的使用 ...

  10. fiddler 进行Android/IOS代理配置抓包

    1.准备:Android+IOS设备 下载:fiddler抓包工具,不是最新版的链接:   链接:https://pan.baidu.com/s/1BaBfu2H4xgpsh1wmkfC8aQ     ...

随机推荐

  1. sql查询 ,多行数据合并成一行,并且显示合并后某一列的值拼接结果

    select  [value] = stuff((select ','+modmb003  from modmb detail where modmb=18 for xml path('')), 1, ...

  2. 【转载】NonEmpty和Non Empty的区别

    转载来源:http://www.ssas-info.com/analysis-services-articles/50-mdx/2196-mdx-non-empty-vs-nonempty One o ...

  3. Block为什么使用Copy?

    block:本质就是一个object-c对象block:存储位置,可能分为3个地方:代码去,堆区.栈区(ARC情况下会自动拷贝到堆区,因此ARC下只能有两个地方:代码去.堆区)代码区:不访问栈区的变量 ...

  4. Hrbust 2319 Number Game(贪心)

    题目链接  Hrbust 2319 首先把二元组排序,$ai$大的排前面,$ai$相同的$bi$大的排前面. 这样的话就满足了Kim的取数顺序,即选每次$ai$最大的. 考虑得坏一些,在$ai$相同的 ...

  5. centos 7 mysql 离线安装教程

    1. 解压下载的zip包,会发现有以下几个rpm包: MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm MySQL-devel-advanced-5.6.22 ...

  6. 2016集训测试赛(二十四)Problem C: 棋盘控制

    Solution 场上的想法(显然是错的)是这样的: 我们假设棋子是一个一个地放置的, 考虑在放置棋子的过程中可能出现哪些状态. 我们令有序整数对\((i, j)\)表示总共控制了\(i\)行\(j\ ...

  7. 最好PHP开发工具Zend Studio 9.0.2的安装和使用

    摘要:Zend Studio是Zend Technologies开发的PHP语言集成开发环境(IDE),是公认最好的PHP开发工具.在5.5系列后,官方推出的Zend Studio都利用了Eclips ...

  8. 2017.2.21 activiti实战--第十三章--流量数据查询与跟踪(一)查询接口介绍及运行时数据查询

    学习资料:<Activiti实战> 第十三章 流量数据查询与跟踪 本章讲解运行时与历史数据的查询方法.主要包含三种:标准查询,Native查询,CustomSql查询. 13.1 Quer ...

  9. linux中find的用法

    找所在目录的文件用 find -name “file*” -print  #注意不要用加文件路径,查找文件也好用双双引号括住: 也可以 find ./ -name “file*” -print

  10. 浅谈PHP与手机APP开发即API接口开发

    API(Application Programming Interface,应用程序接口)架构,已经成为目前互联网产品开发中常见的软件架构模式,并且诞生很多专门API服务的公司,如:聚合数据(http ...