Post

Replies

Boosts

Views

Created

SwiftUI: Navigation title overlapping content of `TabView` after "tap to scroll to the top" on `tabItem`
Hi, Since iOS 18 we now have a built-in "tap on item to scroll to the top" functionality into TabView, which is great but it does have a UI glitch on real devices, it works correct on simulators running from Xcode. The real device I am testing is on iOS 18.2.1 It looks like this: If I then try to scroll the list it snaps back to a offset bellow the navigation title, so fro the looks of it the "scroll to top" was not really to the top but some offset under it. The View is declared like this: struct ContentView: View { private var tabSelection: Binding<String> { Binding( get: { selectedTab }, set: { selectedTab = $0 } )} @State private var selectedTab: String = "Test" var body: some View { TabView(selection: tabSelection, content: { NavigationStack { List { ForEach(0...1000, id: \.self) { index in Text("Test 1 - Row: \(index)") } } .navigationTitle("Test 1") } .listStyle(.insetGrouped) .tabItem { Image(systemName: SFSystemName.morning) Text("Test") } .tag("Test") }) .tabViewStyle(.sidebarAdaptable) } } Any ideas how to resolve this.
Topic: UI Frameworks SubTopic: SwiftUI
2
2
422
Jan ’25
SwiftUI: How do you do CoreData backup and restore?
Hi, I am trying to create a local backup + restore when using SwiftUI and CoreData but I am facing errors left and right. the latest error I am stuck on is: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'executeFetchRequest:error: A fetch request must have an entity.' Here is what am trying to do: Creating a backup (already solved using NSPersistentStoreCoordinator.migratePersistentStore(_:to:options:type:)) Create a new NSPersistentContainer and call its NSPersistentContainer.loadPersistentStores(completionHandler:) (already solved, load is successful) Update the .environment(.managedObjectContext, viewModel.context) so that SwiftUI uses the new context. (HERE is where the error appears) Any help would be appreciated. Here is some sample code of SwiftUI part of the main view: class ViewModel: ObservableObject { @Published var context: NSManagedObjectContext } @main struct MyApp: App { @StateObject var viewModel: ViewModel var body: some Scene { WindowGroup { ContentView() .environment(\.managedObjectContext, viewModel.context) } } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
230
Mar ’25
SwiftUI: How to change `contentInset` of `List`
Hi, Is there any way of changing the contentInset (UIKit variant) of a List in SwiftUI? I do not see any APIs for doing so, the closest I gotten is to use safeAreaInset . While visually that works the UX is broken as you can no longer "scroll" from the gap made by the .safeAreaInset(edge:alignment:spacing:content:) I have subbmited a feedback suggestion: FB16866956
0
0
173
Mar ’25
AppIntent, should I delete previous donations to the system and how?
Hi, In my application I am donating AppIntent instances that I have to the system using the donate() API. I recently came across this article that talks about deleting donations but it does not mention how to handle AppIntent instances. I am wondering when working with dynamic AppIntents (with different properties that can change in the future), should I be worried about "outdated" donated AppIntent instances? And if yes how can I delete previously donated AppIntent instances.
0
0
208
Mar ’25