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传值的更多相关文章

  1. ios中两个view动画切换

    @interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain) ...

  2. IOS中两个view的切换

    在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secon ...

  3. 通知模式实现两个textField传值及模态视图——iOS开发

    通知模式实现两个textField传值及模态视图--iOS开发 利用通知模式,实现两个不同界面的textField之间的传值,在界面二输入字符,传值到前一界面的textField. 界面的切换,这里临 ...

  4. 【项目经验】之——Controller向View传值

    我们的ITOO进行了一大部分了,整体上来说还是比较顺利的.昨天进行了一次验收,大体上来说,我们新生这块还是可以的.不仅仅进行了学术上的交流,还进行了需求上的更新.也正是由于这一次,我有了解到了一个新的 ...

  5. ASP.NET MVC Controller向View传值方式总结

    Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...

  6. 详解iOS开发之自定义View

    iOS开发之自定义View是本文要将介绍的内容,iOS SDK中的View是UIView,我们可以很方便的自定义一个View.创建一个 Window-based Application程序,在其中添加 ...

  7. MVC:Controller向View传值方式总结

    Controller向View传值方式总结 总结发现ASP.NET MVC中Controller向View传值的方式共有6种,分别是: ViewBag ViewData TempData 向普通Vie ...

  8. UIButton的两种block传值方式

    UIButton的两种block传值方式 方式1 - 作为属性来传值 BlockView.h 与 BlockView.m // // BlockView.h // Block // // Create ...

  9. IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法

    在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...

随机推荐

  1. 【LOJ】#2270. 「SDOI2017」天才黑客

    题解 显然要记录每个点来的状态,这样会扩充出点度的平方条边,就gg了 删掉所有的点,把每个边拆成两个点,连一条边权为c 这个时候我们考虑对于原先的每个点,将所有与其相连边所需要的节点(不管是进入还是出 ...

  2. 【LeetCode】287. Find the Duplicate Number

    Difficulty:medium  More:[目录]LeetCode Java实现 Description Given an array nums containing n + 1 integer ...

  3. 洛谷AC200纪念

  4. Python3 k-邻近算法(KNN)

    # -*- coding: utf-8 -*- """ Created on Fri Dec 29 13:13:44 2017 @author: markli " ...

  5. 自己的reset.css

    复制.粘贴 /* http://www.cnblogs.com/ele-cat Reset Stylesheet v1.0.1 2018-05-08 Author: Ele-cat - http:// ...

  6. 用户组修改工具samusrgrp

    用户组修改工具samusrgrp   Windows系统内置了很多用户组,如Administrators.PowerUser.User等.用户隶属不同的组,就具备对应的权限.Kali Linux提供一 ...

  7. JavaScript 的装饰器:它们是什么及如何使用

    请访问我的独立博客地址:https://imsense.site/2017/06/js-decorator/ 装饰器的流行应该感谢在Angular 2+中使用,在Angular中,装饰器因TypeSc ...

  8. Codeforces Round #370 (Div. 2) C. Memory and De-Evolution 水题

    C. Memory and De-Evolution 题目连接: http://codeforces.com/contest/712/problem/C Description Memory is n ...

  9. 有强大的cURL,忘掉httpclient的吧!

    这段时间想做一个网页采集的程序,由于一网站采用了防采集的办法,我的httpclient总是在登录后无法获取到我想要过去的链接.在无数次的跟踪过后发现原来人家给返回的是javascript拼成的页面,而 ...

  10. 国外IOS UI指南

    国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...