Post

Replies

Boosts

Views

Activity

Reply to SwiftUI view not updated after SwiftData change through CloudKit
@effenix Have you able to resolve your issue? Having the same one, here is the example: struct ContentView: View { @Query(sort: \File.name) private var files: [File] var body: some View { NavigationStack { FilesView(files: files) // <- Just wrapped the code into a separate view } } } struct FilesView: View { var files: [File] var body: some View { ForEach(files) { file in NavigationLink(value: file) { FileTileView(file: file) // <- Another extracted view } } } } struct FileTileView: View { var file: File var body: some View { Text(file.name) // <- Doesn't get updated when CloudKit received the sync update } } It does work without the wrappers: @Model final class File { var name: String = "" // <- I edit the name on another device in the simple text editor, the editor code is ommited as it's not significant init(name: String) { self.name = name } } struct ContentView: View { @Query(sort: \File.name) private var files: [File] var body: some View { NavigationStack { ForEach(files) { file in NavigationLink(value: file) { Text(file.name) // <- The text updates successfully after CloudKit sync } } } } }
Mar ’24
Reply to SwiftUI BottomBar Toolbar on parent view breaks leading navigation swipe on iOS 17.0
On iOS 17.4 placing the .toolbar(.visible, for: .bottomBar) on the view which has the toolbar with the toolbar items placed as .bottomBar solved this issue where back swipe brakes navigation and also the issue with toolbar dissapearing after swipe back. Here is pseudocode of my views with which I had both the broken navigation and dissapearing bottom toolbar issues: NavigationSplitView { SidebarView .toolbar(.visible, for: .bottomBar) // <- solves all issues .toolbar { // with this toolbar I had broken navigation as described in the original question ToolbarItem(placement: .bottomBar) { ... } } } detail: { DetailView .toolbar { // with this one I had an issue with this toolbar as so as the sidebar's toolbar dissapearing after trying to swipe left ToolbarItem(placement: .bottomBar) { ... } } }
Mar ’24