Post

Replies

Boosts

Views

Activity

Reply to Why does ForEach initialize its Child View twice as much in SwiftUI?
I encountered this problem for a LazyVStack. My solution worked for me. Once you determine that the ForEach is called twice, use some debugging to determine where and why the view may be re-rending twice. Sometimes swift may re-render a view and in this case the ForEach may appear twice inside the VStack, as ForEach acts as its own Collection for views. https://developer.apple.com/documentation/swiftui/foreach As for the debugging part, try putting a .onAppear( //print something and add a break point ){} on the ForEach (Tested), if it is called twice you know that it is re-rendered twice. 1 - see the changes that occur between the first break point and the second break point to see the changes I hope this can help someone else that experiences the same issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to Cannot preview SwiftUI
I had this problem when I added a folder and was using the cloud storage. I simply removed the folders added and added them again. Make sure to select both "Create Groups" and "Create Items ..". Usually it is "Create a folder reference" by default. I hope this information can help someone looking for a quick solution.
Dec ’21