Hi! I want to allow user to scroll a long list of items iOS app, so I am trying to embbed a List view in ScrollView view. However, the preview result doesn't work. Can you help me to check what I am missing?
Below is my experimental code I entered to the file ContentView.swift, started with Single Page App project.
struct ContentView: View {
var body: some View {
ScrollView{
List{
Text("abc")
Text("def")
}
.border(Color.yellow, width: 3)
.background(Color.blue)
}.padding(10).border(Color.red, width: 3)
}
}
The preview of this code shows the red borders of the ScrollView, but not showing anything for the list, nor the text inside. If I change "List" to "VStack", then everything worked as expected.
I don't understand why List doesn't work, and don't know how to fix it. Can you help me to find some clue?
Thank you!