【发布时间】:2021-01-28 06:36:15
【问题描述】:
SwiftUI Horizontal ScrollView 项目在 iOS 14.3 中滚动时变得不可见,但在 iOS 13 中可以正常工作
GeometryReader { geometry in
ZStack (alignment: .center) {
Color(UIColor(hexString: "#F2F2F7"))
.edgesIgnoringSafeArea(.all)
VStack(alignment: .center){
ScrollView (.horizontal, showsIndicators: false) {
LazyHStack {
//contents
ForEach(0..<200)
{ index in
Text(String(index))
}
}}
.frame(maxWidth: .infinity) // << here !!
.frame(height: 100)
}
}}
【问题讨论】:
-
提供的代码在 Xcode 12.3 iOS 14.3 上运行良好。此外,LazyHStack 不适用于 iOS 13。因此请提供完整的复制代码。
-
对我也很有效,但需要使用:Text(String(index)) 或 Text("(index)")
-
@Raja 是的,LazyHStack 在 iOS 13 中不可用,但对于 iOS 13,我只使用了 HStack
-
@workingdog 完成了同样的问题
-
@AdeyemiSeun 请添加完整结构
标签: swiftui ios14 swiftui-scrollview