Help us understand the problem. What is going on with this article?

SwiftUIでScrollViewが更新されない時の対処法

ScrollView(ForEach)で参照している配列の値をCombineを使って動的に更新した際に、Viewが反映されない事象が起きた。
データの送受信でバグがあるのかとも考えたが、Listにしたところ問題なく反映されたので色々調べたがピンポイントな解決策がなかなか見つからなかったのでQiitaにも残しておく。

環境

Xcode 11.3(11C29)

解決策

結果的に空配列ではなく、なにかしらの初期値をセットしておくことで動的に更新されるようになった。

@Published var items: [String] = [""]

以下のStack Overflowの回答で解決した :pray:

ios - SwiftUI ForEach not correctly updating in scrollview - Stack Overflow
https://stackoverflow.com/questions/59316078/swiftui-foreach-not-correctly-updating-in-scrollview

--

yamshta
TITE(タイト) - タイムテーブル形式の勉強会検索アプリ https://goo.gl/ixsXWJ
http://techblog.lclco.com/
lclco
全国の高速バス価格情報を比較・検索できるサービスサイトを運営
https://www.lclco.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした