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" ...
随机推荐
- LOJ 10160 - 「一本通 5.2 练习 3」周年纪念晚会 / 没有上司的晚会
题面 传送门 Ural 州立大学的校长正在筹备学校的 8080 周年纪念聚会.由于学校的职员有不同的职务级别,可以构成一棵以校长为根的人事关系树.每个资源都有一个唯一的整数编号,从 $1$ 到 $N$ ...
- hdu 2545 求当前结点到根节点的距离
求当前结点到根节点的距离 Sample Input 2 1 //n m 1 2 1 2 //询问 5 2 1 2 1 3 3 4 3 5 4 2 //询问 4 5 0 0 Sample Output ...
- Django为数据库的ORM写测试例(TestCase)
models.py里的数据库定义如下: from django.db import models # Create your models here. class Teachers(models.Mo ...
- MVC底层原理
窥探ASP.Net MVC底层原理 实现跨越Session的分布式TempData 1.问题的引出 我相信大家在项目中都使用过TempData,TempData是一个字典集合,一般用于两个请求之间临时 ...
- 2018年长沙理工大学程序设计竞赛 J - 杯子
题意: 链接:https://www.nowcoder.com/acm/contest/96/J一天durong同学买了一个无限长的杯子,同时买了n个球,并且标号为1,2,3......n,duron ...
- 008 jquery过滤选择器-----------(子元素过滤选择器)
1.介紹 2.程序 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- 005 jquery过滤选择器-----------(内容过滤选择器)
1.介绍 2.程序 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...
- MySQL 中国省市区SQL表数据
MySQL 中国省市区SQL表数据 1.查省SELECT * FROM china WHERE china.Pid=02.查市SELECT * FROM chinaWHERE china.Pid= ...
- [代码审计]eyoucms前台未授权任意文件上传
0x00 背景 来公司差不多一年了,然而我却依旧没有转正.约莫着转正也要到九月了,去年九月来的,实习,转正用了一年.2333 废话不多说了,最近有其他的事要忙,很久没有代码审计了.难的挖不了,浅的没意 ...
- OpenVPN使用easy-rsa3吊销证书
cd /etc/easy-rsa ./easyrsa revoke targetkey(证书名) ./easyrsa gen-crl 其中gen-crl会生成一份吊销证书的名单,放在pki/crl.p ...