当前位置:网站首页>Swiftui view onReceive method receives "redundant" event resolution
Swiftui view onReceive method receives "redundant" event resolution
2022-07-27 20:40:00 【Giant panda Hou Pei】

summary
As we all know ,SwiftUI It provides us with convenient onReceive Modifier method , To receive events sent by external publishers .
But in some cases , We need to shield some irrelevant “ redundancy ” event .
such as ,SwiftUI Medium Picker The publisher corresponding to the bound value , It's always there Picker Send an event when creating , This is what we don't want :

As shown above ,Picker Views can be created by users on demand , But every time it is created, it will send a change event of the binding property .
How to avoid receiving this “ It's useless ” What about the incident ?
Actually , Just a small change in the code , We can fix this problem perfectly !
Let’s go!
Source code reproduction
The relevant source code is as follows :
@objc(BSUToday)
public 边栏推荐
- Scrollintoview realizes simple anchor location (example: select city list)
- Standing on the shoulders of giants to learn, jd.com's popular architect growth manual was launched
- In 2019, China's smart machine Market: Huawei won nearly 4 components, firmly ranking first in China
- 我也是醉了,Eureka 延迟注册还有这个坑
- Redis queue, RDB learning
- JVM overview and memory management (to be continued)
- JD: get the raw data API of commodity details
- ES6 -- Deconstruction assignment
- Pyqt5 rapid development and practice 4.7 qspinbox (counter) and 4.8 QSlider (slider)
- IE11 下载doc pdf等文件的方法
猜你喜欢

Two years after its release, the price increased by $100, and the reverse growth of meta Quest 2

Data warehouse construction - DWD floor

Redis basic understanding, five basic data types

预处理与宏定义

盘点下互联网大厂的实习薪资:有了它,你也可以进厂

Understand the wonderful use of dowanward API, and easily grasp kubernetes environment variables

图解LeetCode——592. 分数加减运算(难度:中等)
![[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration](/img/38/9fadea0d37053a3ebb73806a9963f1.jpg)
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration

站在巨人肩膀上学习,京东爆款架构师成长手册首发

Mlx90640 infrared thermal imager temperature sensor module development notes (VII)
随机推荐
MySQL 日志错误日志
Knowledge dry goods: basic storage service novice Experience Camp
Technology sharing | how to do Assertion Verification in interface automated testing?
Preprocessing and macro definition
获得微店商品详情 API
LG Group announced that it would donate 3million yuan in cash, 1.2 million masks and 10000 sets of protective clothing to Hubei
Express: search product API by keyword
多点双向重发布及路由策略的简单应用
Pyqt5 rapid development and practice 4.3 qlabel and 4.4 text box controls
Assignment 1 - Hello World ! - Simple thread Creation
What app should individuals use for stock speculation to be safer and faster
Mlx90640 infrared thermal imager temperature sensor module development notes (VII)
Redis-基本了解,五大基本数据类型
CONDA common commands
shell
To share the denoising methods and skills of redshift renderer, you must have a look
Slf4j introduction
Scrollintoview realizes simple anchor location (example: select city list)
Why do we need third-party payment?
slf4j简介说明