См. пример
Код: Выделить всё
import SwiftUI
import SwiftData
struct ContentView: View {
@Query private var items: [Item]
private var itemsBis: [String] {
Array(repeating: "Item ", count: 100)
}
var body: some View {
NavigationSplitView {
List {
ForEach(items) { item in
NavigationLink {
TabView {
Tab("Tab 1", systemImage: "house") {
Form {
ForEach(Array(itemsBis.enumerated()), id: \.offset) { index, item in
Text("\(item) \(index + 1)")
}
}
}
Tab("Tab 2", systemImage: "circle") {
Form {
ForEach(Array(itemsBis.enumerated()), id: \.offset) { index, item in
Text("\(item) \(index + 1)")
}
}
}
Tab("Tab 3", systemImage: "gear") {
Form {
ForEach(Array(itemsBis.enumerated()), id: \.offset) { index, item in
Text("\(item) \(index + 1)")
}
}
}
}
} label: {
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
}
}
}
} detail: {
Text("Select an item")
}
}
}
#Preview {
ContentView()
.modelContainer(for: Item.self, inMemory: true)
}
Какие изменения мне следует внести, чтобы избежать такого поведения?
Подробнее здесь: https://stackoverflow.com/questions/790 ... hind-title