#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. Java IO 学习(四)BIO/NIO

    本文会尝试介绍Java中BIO与NIO的范例与原理 使用的模型非常简单:服务器--客户端模型,服务器会将客户端发送的字符串原样发回来.也就是所谓的echo server. BIO 也就是所谓的Sock ...

  2. 爬虫学习笔记(六)PyQuery模块

    PyQuery模块也是一个解析html的一个模块,它和Beautiful Soup用起来差不多,它是jquery实现的,和jquery语法差不多,会用jquery的人用起来就比较方便了. Pyquer ...

  3. 专利事务所信息Python爬取

    数据来源:http://www.acpaa.cn/ 目前事务所的信息没有做反爬限制,还是很容易拿到数据的 没有用html解析工具,直接上正则,结果就是需要处理很多乱七八糟的空格...为了能将日期顺利的 ...

  4. 暂停时间 以及dict 循环

    暂停时间 #!/usr/bin/python # -*- coding: UTF-8 -*- import time myD = {1: 'a', 2: 'b'} for key, value in ...

  5. Maven错误“Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create ”解决

    用maven3新建一个项目时,输入的命令如下: mvn archetype:create 出现错误如下: [ERROR] Failed to execute goal org.apache.maven ...

  6. delphi中如何将string类型的字符串数据转化成byte[]字节数组类型的数据

    var  S:String;  P:PChar;  B:array of Byte;begin  S:='Hello';  SetLength(B,Length(S)+1);  P:=PChar(S) ...

  7. Excel找出两列相同部分

    公式:=IF(COUNTIF($B$2:$B$1036,A6)>0,A2,"") 含义:从B列第2行到b列1036行中和A列第6个相等的返回A6的值,不相等返回空 用法:新建 ...

  8. mysql 性能容量评估

    性能容量评估   分析上线业务场景 评估数据库服务器所需性能指标 预估可能成为瓶颈的服务器资源 帮助数据库性能调优   数据库服务器硬件性能指标项: 磁盘IO性能 内存容量 CPU 网络吞吐量 磁盘容 ...

  9. Git之Github使用(一):Push代码到Github

    Git之Github使用(一):Push代码到Github 热度 2已有 58 次阅读2016-8-26 17:56 |个人分类:常见问题|系统分类:移动开发| 互联网, commit, status ...

  10. mac 配置sencha touch环境

    1 安装 java 2 安装 node js 为使用npm作准备 3 用npm命令安装 cordova npm install -g cordova