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" ...
随机推荐
- Spring Cloud微服务视频教程-百度云
Spring Cloud微服务视频教程-百度云 链接:https://pan.baidu.com/s/1mp8SkxNw7EfoTDtDKQMpIA 提取码: 关注公众号[GitHubCN]回复521 ...
- AndroidManifest.xml配置文件详解 (转)
原文:http://blog.csdn.net/shagoo/article/details/7485958# AndroidManifest.xml配置文件对于Android应用开发来说是非常重要的 ...
- 【Java】 大话数据结构(15) 排序算法(2) (快速排序及其优化)
本文根据<大话数据结构>一书,实现了Java版的快速排序. 更多:数据结构与算法合集 基本概念 基本思想:在每轮排序中,选取一个基准元素,其他元素中比基准元素小的排到数列的一边,大的排到数 ...
- win10无线网连接 提示无法连接到此网络
一.Win10无法连接此网络是怎么回事 对于大多数遇到无法连接此网络问题的,主要是Win10笔记本电脑用户,使用的是无线网络.而出现Win10连接其他无线网络正常,但是就是某个无线网络无法正常连接的时 ...
- cv2 与 matplotlib 的 Bug 记录
cv2 的 imread 无法读取中文路径 解决方案: img = cv2.imdecode(np.fromfile(image_path,dtype=np.uint8),cv2.IMREAD_COL ...
- JAVA 图形界面开发基础详解
与C的win32一样,JAVA也有自己的图形界面开发,将在此篇博客中对基础部分进行讲解. 1.Java提供的图形界面类有哪些? Java提供了两套图形界面 (1)AWT组建(基础) AWT组件是jdk ...
- .NET工作准备--03进阶知识
(已过时) 高级特性,多线程编程,单元测试; 第一部分 .net高级特性 1.委托:提供安全的函数回调机制; *基本原理:与C++中的函数指针相似;安全--它和其他所有.net成员一样是一种类型,任何 ...
- 火狐浏览器接口测试工具Poster
- [CC-FNCS]Chef and Churu
[CC-FNCS]Chef and Churu 题目大意: 一个长度为\(n(n\le10^5)\)的数列\(A_{1\sim n}\),另有\(n\)个函数,第\(i\)个函数会返回数组中标号在\( ...
- bzoj 2648: SJY摆棋子&&2716: [Violet 3]天使玩偶 --kdtree
2648: SJY摆棋子&&2716: [Violet 3]天使玩偶 Time Limit: 20 Sec Memory Limit: 128 MB Description 这天,S ...