#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *contentTxtField;

@end

#import "SecondViewController.h"

#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (IBAction)jumpToSecondBtnClick:(UIButton *)sender

{

UIStoryboard *firstSb=[UIStoryboard storyboardWithName:@"Main" bundle:nil];

SecondViewController *secondCtl=[firstSb instantiateViewControllerWithIdentifier:@"second"];

[secondCtl compeleteBlock:^(NSString *string) {

_contentTxtField.text=string;

}];

[self.navigationController pushViewController:secondCtl animated:YES];

}

@end

#import <UIKit/UIKit.h>

typedef void (^BlockPassValue) (NSString *string);

@interface SecondViewController : UIViewController

{

BlockPassValue myBlockValue;

}

@property (weak, nonatomic) IBOutlet UITextField *valueTxtField;

-(void)compeleteBlock:(BlockPassValue)myblock;

@end

#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

-(void)compeleteBlock:(BlockPassValue)myblock

{

myBlockValue=myblock;

}

- (IBAction)backToFirstBtnClick:(UIButton *)sender

{

if (myBlockValue)

{

myBlockValue(_valueTxtField.text);

}

[self.navigationController popViewControllerAnimated:YES];

}

@end

iOS block进行页面之间传值的更多相关文章

  1. iOS学习之页面之间传值的方式总结

    传值三种场景: 1.属性传值(从前往后传) 需求:第二个界面标签显示第一个界面输入框文字. 第一步, 在前一个界面定义属性. (语义属性声明为copy); 第二步, 在进入下一个界面之前,给属性传入数 ...

  2. Block作为property属性实现页面之间传值(代替Delegate代理与协议结合的方法)

    需求:在ViewController中,点击Button,push到下一个页面NextViewController,在NextViewController的输入框TextField中输入一串字符,返回 ...

  3. ASP.NET 页面之间传值的几种方式

    开篇概述 对于任何一个初学者来说,页面之间传值可谓是必经之路,却又是他们的难点.其实,对大部分高手来说,未必不是难点. 回想2016年面试的将近300人中,有实习生,有应届毕业生,有1-3年经验的,有 ...

  4. 【ASP.NET MVC系列】浅谈ASP.NET 页面之间传值的几种方式

    ASP.NET MVC系列文章 [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作 ...

  5. asp.net页面之间传值方法详解

    asp.net中页面之间传值我们用得最多的就是get,post这两种了,其它的如session,appliction,cookie等这些相对来说少用也不是常用的,只是在特殊情况下在使用了. 1. Ge ...

  6. js父页面和子页面之间传值

    今天和朋友一块讨论,怎样通过js在父页面和子页面之间传值的问题,总结例如以下: 需求描写叙述:父页面有多个子页面.实如今父页面点击子页面,传值到子页面. 看着非常easy,试了好久.主要纠结在怎样获取 ...

  7. 【微信小程序】mpvue中页面之间传值(全网唯一真正可行的方法,中指推了一下隐形眼镜)

    摘要: mpvue中页面之间传值(注意:是页面之间,不是组件之间) 场景:A页面跳转B页面,在B页面选择商品,将商品名带回A页面并显示 使用api: getCurrentPages step1: A页 ...

  8. 页面之间传值方式的总结,五种方式,通知,block,代理,单例,NSUERDEFALUT,

    首先代码拿上 1:单例 2:通知 3:代理 4:block方法 5:NSUSERDEFAULT(沙盒文件) 先是单例类: .h文件 @interface DataSource : NSObject @ ...

  9. 【Win10开发】如何在页面之间传值

    我们知道UWP是通过不同的页面来展示不同的内容的,那么我们该怎么进行页面之间的传值呢? 首先我们在MainPage里面写一个ListView来展示一些英文单词. List<English> ...

随机推荐

  1. C语言中返回字符串函数的四种实现方法 2015-05-17 15:00 23人阅读 评论(0) 收藏

    C语言中返回字符串函数的四种实现方法 分类: UNIX/LINUX C/C++ 2010-12-29 02:54 11954人阅读 评论(1) 收藏 举报 语言func存储 有四种方式: 1.使用堆空 ...

  2. 串口发送浮点型数据及int(2个字节)long int(4个字节)的方法

    方法一: 直接把float数据拆分为4个unsigned char(由于数字没法拆分,所以只能用指针的),发过去,在合并为float. 其中有两点要注意. (1)大端存储,小端存储:如果搞错读取数据就 ...

  3. codeforces 601A The Two Routes(最短路 flody)

    A. The Two Routes time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. linux极点五笔无法输入词组_ibus设置

    菜鸟学linux——用的是ubuntu 不知道是不是按个哪些快捷键,极点五笔突然无法输入词组.那个抓狂啊 没关系,设置一下就ok 第一步:右上角输入法,右键——>首选项——>常规——> ...

  5. WinHTTP Web Proxy Auto-Discovery Service

    下面是网上搜集的,个人没有做测试,----------------------------- WinHTTP Web Proxy Auto-Discovery Service 服务成功发送一个 开始 ...

  6. 编译安装-Apache

    一.配置选项说明 二.安装apache 1.环境准备 2.安装apr 3.安装apr-util 4.安装pcre 5.安装httpd 6.修改配置文件 7.开机自启动 8.注册为服务 9.测试 一.配 ...

  7. 80X86保护模式及其编程(一)

    80x86系统寄存器和系统指令 1.标志寄存器(EFLAGS) 标志寄存器EFLAGS的标志位含义如下图: TF 位8是跟踪标志(Trace flag),当设置该位时可为调试操作启动单步执行方式.复位 ...

  8. Java Service Wrapper配置详解

    #encoding=UTF-8 # Configuration files must begin with a line specifying the encoding # of the the fi ...

  9. IIS7 “拒绝访问临时目录”

    创建 BlogConfigurationSettings 的配置节处理程序时出错: 拒绝访问临时目录.以其运行 XmlSerializer 的身份“IIS APPPOOL\5656qp.com.rmi ...

  10. UI:UITableView表视图

    表视图 UITableView,iOS中最重要的视图,随处可⻅见. 表视图通常⽤用来管理⼀一组具有相同数据结构的数据. UITableView继承⾃自UIScrollView,所以可以滚动,表视图的每 ...