Hi,I have the issue, when navigating from a Form to a List (see sample code below) the List "jumps" once it appeared. Has anybody else encountered this and maybe a solution/workaround? Or is something wrong with the code?If I remove Text("Other"), it does not jump anymore, but then again I need more than one element in the Form ;-).Cheers, Michaelimport SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
Form {
Text("Other")
NavigationLink(destination: NextView()) {
Text("to Next View")
}
.navigationBarTitle("Here")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
// MARK: - NextView -
struct NextView: View {
var body: some View {
List {
Text("A")
Text("B")
Text("C")
}
.navigationBarTitle("There")
}
}
Post
Replies
Boosts
Views
Activity
Hi,I made a small test program trying to figure out how @FetchRequest, List, ForEach work together with large data sets. At first glance it seems (judging from the memory consumption) that all the entities are loaded and not just those which are displayed (see code below). I am now wondering, if there is a way to setup FetchRequest (or the List, or...) in a way so it does the lazy loading for only visible items? Or is this just not (yet) possible?Here is the SwiftUI coding I am using.import SwiftUI
struct ContentView: View {
@FetchRequest(entity: TrackCoordinate.entity(), sortDescriptors: [])
var tracks: FetchedResults<TrackCoordinate>
var body: some View {
VStack {
List {
ForEach(tracks, id: \.self) { track in
Text("\(track.x) \(track.y)")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}Thanks, Michael
Hello,I recently see sometimes crashing errors with statements like "precondition failure: attribute failed to set an initial value: 103" logged to the console. The numbers at the end vary. Has anybody found a good way (or any way besides blindly trying to change things ;-) to track down those errors?Cheers, Michael
Hi,I have the issue (on iOS/iPadOS) once a NavigationLink was tapped/used it won't trigger the navigation again after navigating back. The most minimal code example would be:struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: PushedView()) {
Text("Press Me").font(.largeTitle)
}
}
}
struct PushedView: View {
var body: some View {
Text("Hello")
}
}
}So once "Push Me" was tapped and the navigation triggered it won't work again after navigating back. (Only tested in simulator so far.) Am I missing something?Kind regards, Michael
Hi,I am having the following issue with multiple targets in a workspace and SwiftUI previews and am wondering, if that's a bug or a feature?I have a workspace containing an iOS and a watchOS target. Both targets have a source file with the name "FooView.swift" in them, which implements the same UI (using SwiftUI of course), but specific for the particular platform. When trying to use SwiftUI previews after switching targets it only works after a full clean of the project. I assume this is because either the filenames or class names clash somewhere.The other issue I saw is that HostingController.swift filename (generted by Xcode) clashes with some generated HostingController.swift file used by the SwiftUI previews in the iOS target. To be clear the iOS target has no HostingViewController.swift. I assume it's generated to "host" the SwiftUI preview. After renaming only the file (not the class) to WatchHostingViewContoller.swift everything was working again.So I am wondering if that should be considered expected behaviour or bugs?Thank you, Michael