#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. pyqt线程实现

    # coding=utf-8 __author__ = 'a359680405' from PyQt5.QtCore import * from PyQt5.QtGui import * from P ...

  2. poj 3169&hdu3592(差分约束)

    Layout Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9687   Accepted: 4647 Descriptio ...

  3. RadioGroup动态添加RadioButton,并且获得事件

    由于有许多的RadioButton是动态的,不是固定的一些,所以需要在代码中,动态的添加到RadioGroup中,下面是我的实现方法. 1.添加RadioButton到RadioGroup中 Radi ...

  4. Codeforces 785D Anton and School - 2(推公式+乘法原理+组合数学)

    题目链接 Anton and School - 2 对于序列中的任意一个单括号对(), 左括号左边(不含本身)有a个左括号,右括号右边(不含本身有)b个右括号. 那么答案就为 但是这样枚举左右的()的 ...

  5. 洛谷——P1098 字符串的展开

    P1098 字符串的展开 题目描述 在初赛普及组的“阅读程序写结果”的问题中,我们曾给出一个字符串展开的例子:如果在输入的字符串中,含有类似于“d-h”或者“4-8”的字串,我们就把它当作一种简写,输 ...

  6. Scut游戏服务器引擎6.5.8.6发布

    1.增加从Redis中加载数据到Cache可设置筛选条件2.修改在Web项目中的不能支持自定协议问题3.修改Share类型的Model在Redis中为空时会尝试从DB中加载数据4.修改Model命名空 ...

  7. PHP计算两个时间的年数、月数以及天数

    如何获取两个不同时间相差几年几月几日呢?比如当前时间距离2008年08月08日的北京奥运会有几年几月几日了?需要说明的是:1.定义一年为360天,一个月为30天:2.代码中86400=24*60*60 ...

  8. 浅谈XXE攻击

    一.XXE,即XML External Entity,XML外部实体.ENTITY 实体,在一个甚至多个XML文档中频繁使用某一条数据,我们可以预先定义一个这条数据的“别名”,即一个ENTITY,然后 ...

  9. fiddler使用心得记录

    fiddler是一款非常好用的软件,通过监听8888端口来修改http,https等请求和响应,是抓包神器. 最近正在学习如何使用,现在记录下学习的一些技巧 如何支持https 点击菜单项tools, ...

  10. 立体3D方式 【转】

    目前为止,至少有四种普遍使用的立体3D传输格式,分别称为frame sequential(帧连续),frame packing(帧封装),side-by-side(并排),以及checkerboard ...