ios之两个view传值
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传值的更多相关文章
- ios中两个view动画切换
@interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain) ...
- IOS中两个view的切换
在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secon ...
- 通知模式实现两个textField传值及模态视图——iOS开发
通知模式实现两个textField传值及模态视图--iOS开发 利用通知模式,实现两个不同界面的textField之间的传值,在界面二输入字符,传值到前一界面的textField. 界面的切换,这里临 ...
- 【项目经验】之——Controller向View传值
我们的ITOO进行了一大部分了,整体上来说还是比较顺利的.昨天进行了一次验收,大体上来说,我们新生这块还是可以的.不仅仅进行了学术上的交流,还进行了需求上的更新.也正是由于这一次,我有了解到了一个新的 ...
- ASP.NET MVC Controller向View传值方式总结
Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...
- 详解iOS开发之自定义View
iOS开发之自定义View是本文要将介绍的内容,iOS SDK中的View是UIView,我们可以很方便的自定义一个View.创建一个 Window-based Application程序,在其中添加 ...
- MVC:Controller向View传值方式总结
Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...
- UIButton的两种block传值方式
UIButton的两种block传值方式 方式1 - 作为属性来传值 BlockView.h 与 BlockView.m // // BlockView.h // Block // // Create ...
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...
随机推荐
- hdu 5443 (2015长春网赛G题 求区间最值)
求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...
- CMU-15445 LAB1:Extendible Hash Table, LRU, BUFFER POOL MANAGER
概述 最近又开了一个新坑,CMU的15445,这是一门介绍数据库的课程.我follow的是2018年的课程,因为2018年官方停止了对外开放实验源码,所以我用的2017年的实验,但是问题不大,内容基本 ...
- MyBatis Plus + Activiti 整合报错:org.springframework.beans.factory.UnsatisfiedDependencyException
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ind ...
- spring 状态机
前言:“状态机”见名知意,用状态去管理业务操作,打个比方:0~1岁(出生状态),1~3岁(认知状态),3~6岁(启蒙状态),6~22岁(学习状态),22~60(工作状态),60以后(退休状态),那么人 ...
- iOS 11开发教程(十四)iOS11应用代码添加视图
iOS 11开发教程(十四)iOS11应用代码添加视图 如果开发者想要使用代码为主视图添加视图,该怎么办呢.以下将为开发者解决这一问题.要使用代码为主视图添加视图需要实现3个步骤. (1)实例化视图对 ...
- [POI2013]Łuk triumfalny
[POI2013]Łuk triumfalny 题目大意: 一棵\(n(n\le3\times10^5)\)个结点的树,一开始\(1\)号结点为黑色.\(A\)与\(B\)进行游戏,每次\(B\)能选 ...
- BZOJ4242 : 水壶
对于任意两个建筑物,以它们之间的最短路为边权求出最小生成树. 则询问(x,y)的答案为最小生成树上x到y路径上边权的最大值. BFS求出离每个点最近的建筑物以及到它的距离,可以发现只有交界处的边才有用 ...
- UVALive 6913 I Want That Cake 博弈dp
I Want That Cake 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemi ...
- ELASTIC 5.2部署并收集nginx日志
elastic 5.2集群安装笔记 设计架构如下: nginx_json_log ->filebeat ->logstash ->elasticsearch ->kiban ...
- Eclipse中执行Maven命令时控制台输出乱码
Maven 默认编码为 GBK: 在 Eclipse 控制台输出乱码: 解决方法:将以下代码添加到 pom.xml 的 <project> 节点下: <project> …… ...