Post marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
Post marked as solved with 2 replies, 0 views
Replied In
List sections empty after adding .id()
Although @snuff4's answer solved the empty cells issue in my real project, scrolling to desired cell/row wasn't working when using ScrollViewReader's scrollTo method.
I have come up with a weird fix that works for me. It is weird because I don't know how and why it works, but it works. If anyone can explain why it works, I'll be very thankful.
The solution is, I created a new ViewModifier named EmbedInSection that just embeds the content in Section.
struct EmbedInSection: ViewModifier {
func body(content: Content) -> some View {
Section {
content
}
}
}
And I used it like:
var body: some View {
List {
ForEach(intervals) { interval in
Text(interval.name)
.id(interval.id)
.modifier(EmbedInSection())
}
}
}