Вы можете полностью скопировать это на игровую площадку для воспроизведения. При запуске предварительный просмотр выглядит хорошо, но при прокрутке вверх и вниз элементы (HStack) исчезают. Я понятия не имею, почему ... Это ошибка Apple или в чем я не понимаю?
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
import SwiftUI
struct Cell : View {
var country: String
var body: some View {
VStack() {
Text("OMG").onAppear() { print ("OMG") }
ScrollView(.horizontal) {
HStack() {
Text(country)
}.background(Rectangle().fill(Color.blue))//.frame(height: 195)
}.background(Rectangle().fill(Color.orange))//.frame(height: 205)
}
}
}
struct ContentView: View {
var countries = ["a", "b", "c", "d", "e", "f", "g", "h"]
init() {
UITableView.appearance().showsVerticalScrollIndicator = false
UITableView.appearance().showsHorizontalScrollIndicator = false
}
var body: some View {
GeometryReader() { geometry in
VStack() {
Text("Title")
List(self.countries, id: \.self) { country in
Cell(country: country)
}.environment(\.defaultMinListRowHeight, 340)
}
}
}
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = UIHostingController(rootView: ContentView())