当前位置:网站首页>使用block实现两个页面之间的传统价值观
使用block实现两个页面之间的传统价值观
2022-07-06 10:18:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
第二个view声明一个block属性:
@property (nonatomic, copy) void(^doTransferMsg)(NSString *_msg);
然后传值方法里检查block是不是存在
– (IBAction)transferText:(UIButton *)sender { if (_doTransferMsg) { _doTransferMsg(@”hello there”); _doTransferMsg = nil; } [self.navigationController popViewControllerAnimated:YES]; }
主View里。创建第二个view的时候。顺便实现这个block
– (IBAction)LoadDetailView:(UIButton *)sender { [ibTextLabel setText:nil]; DetailViewController *_curDetail = [[DetailViewController alloc] initWithNibName:@”DetailViewController” bundle:nil]; [_curDetail setDoTransferMsg:^(NSString *_msg) { dispatch_async(dispatch_get_main_queue(), ^{ [ibTextLabel setText:_msg]; }); }]; [self.navigationController pushViewController:_curDetail animated:YES]; [_curDetail release]; }
that’s all
版权声明:本文博客原创文章,博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117387.html原文链接:https://javaforall.cn
边栏推荐
- 容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
- Jerry's watch reads the file through the file name [chapter]
- Codeforces Round #803 (Div. 2)
- The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly a hundredfold performance improvement
- Four processes of program operation
- Kill -9 system call used by PID to kill process
- 阿里云国际版ECS云服务器无法登录宝塔面板控制台
- Interview assault 63: how to remove duplication in MySQL?
- 重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
- Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
猜你喜欢
從交互模型中蒸餾知識!中科大&美團提出VIRT,兼具雙塔模型的效率和交互模型的性能,在文本匹配上實現性能和效率的平衡!...
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
Jerry is the custom background specified by the currently used dial enable [chapter]
模板于泛型编程之declval
UDP protocol: simple because of good nature, it is inevitable to encounter "city can play"
STM32 key state machine 2 - state simplification and long press function addition
Why does wechat use SQLite to save chat records?
The integrated real-time HTAP database stonedb, how to replace MySQL and achieve nearly a hundredfold performance improvement
Jerry's updated equipment resource document [chapter]
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
随机推荐
The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
MarkDown语法——更好地写博客
Jielizhi obtains the currently used dial information [chapter]
Getting started with pytest ----- test case rules
2022暑期项目实训(一)
Olivetin can safely run shell commands on Web pages (Part 1)
Jerry's watch deletes the existing dial file [chapter]
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
简单易用的PDF转SVG程序
趣-关于undefined的问题
Why does wechat use SQLite to save chat records?
2022暑期项目实训(二)
1700C - Helping the Nature
转载:基于深度学习的工业品组件缺陷检测技术
從交互模型中蒸餾知識!中科大&美團提出VIRT,兼具雙塔模型的效率和交互模型的性能,在文本匹配上實現性能和效率的平衡!...
Kill -9 system call used by PID to kill process
Redis的五种数据结构
Codeforces Round #803 (Div. 2)
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
UDP协议:因性善而简单,难免碰到“城会玩”