I’ve a SwiftUi Record the place every merchandise results in a TabView. When accessing the TabView and scrolling down, the content material of the Tab cross behind the present view toolbar.
import SwiftUI
import SwiftData
struct ContentView: View {
@Question non-public var objects: [Item]
non-public var itemsBis: [String] {
Array(repeating: "Merchandise ", rely: 100)
}
var physique: some View {
NavigationSplitView {
Record {
ForEach(objects) { merchandise in
NavigationLink {
TabView {
Tab("Tab 1", systemImage: "home") {
Type {
ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
Textual content("(merchandise) (index + 1)")
}
}
}
Tab("Tab 2", systemImage: "circle") {
Type {
ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
Textual content("(merchandise) (index + 1)")
}
}
}
Tab("Tab 3", systemImage: "gear") {
Type {
ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
Textual content("(merchandise) (index + 1)")
}
}
}
}
} label: {
Textual content(merchandise.timestamp, format: Date.FormatStyle(date: .numeric, time: .normal))
}
}
}
} element: {
Textual content("Choose an merchandise")
}
}
}
#Preview {
ContentView()
.modelContainer(for: Merchandise.self, inMemory: true)
}
Finally after a number of scrolls or switching tab, the content material will show accurately.
What adjustments ought to I carry to keep away from this habits?
