I found a pure SwiftUI working solution:/// This will init and deinit the content view when selection math tag.struct SyncView<Content: View>: View { @Binding var selection: Int var tag: Int var content: () -> Content @ViewBuilder var body: some View { if selection == tag { content() } else { Spacer() } }}You can use it then in this way:struct ContentView: View {
@State private var selection = 0
var body: some View {
TabView(selection: $selection) {
SyncView(selection: $selection, tag: 0) {
ViewThatNeedsRefresh()
}
.tabItem { Text("First") }
.tag(0)
Text("Second View")
.font(.title)
.tabItem { Text("Second") }
.tag(1)
}
}
}You can use the SyncView for each view that needs a refresh.
Post
Replies
Boosts
Views
Activity
Same for me.
I have the same issue, now. I think the problem stay in laziness of the view... if I use VStack it works, but not with LazyVStack or LazyVGrid. I think for now I'll solved this with nested VStack and HStack...