【发布时间】:2022-07-22 20:44:27
【问题描述】:
var body: some View {
NavigationView {
ZStack {
Color(UIColor.systemGroupedBackground).edgesIgnoringSafeArea(.all)
ScrollView(showsIndicators: false) {
if #available(iOS 15.0, *) {
VStack {
if self.viewModel.forms.isEmpty && !self.viewModel.isLoading {
Text("No Forms Assigned")
.foregroundColor(Color.gray)
.padding(.vertical, 20)
.accessibility(label: Text("No forms assigned"))
}
if self.viewModel.isLoading {
ActivityIndicator(isAnimating: .constant(true), style: .large).padding(.top, 20)
}
noFormsScrollView
Spacer(minLength: 16).accessibility(hidden: true)
}
.refreshable {
self.refreshData()
}
} else {
// Fallback on earlier versions
}
}
}.navigationBarTitle("Forms", displayMode: .inline)
}
}
我正在尝试在我的ScrollView 上添加拉动以刷新但它不起作用。我在想,我做错了什么。
【问题讨论】:
-
究竟是什么不工作?
-
@koen .refreshable 或不工作。
-
我认为它只适用于
List -
不适用于 ScrollView?
-
它会编译得很好,但不会做任何事情。 aheze 是对的,它只适用于 List。