Post

Replies

Boosts

Views

Activity

Reply to SwiftUI TabView with List not refreshing after objected deleted from Core Data
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.
Mar ’20