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)
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试添加拉动以刷新我的ScrollView但它不起作用。我想知道我做错了什么。
看起来在 iOS 16+ 中你可以这样做:
ScrollView {
// view body
}
.refreshable {
// refresh action
}
Run Code Online (Sandbox Code Playgroud)
来源: https ://developer.apple.com/documentation/swiftui/refreshaction https://developer.apple.com/forums/thread/707510
消息来源确实说这个东西是 15+,但它似乎在 15 上不起作用,即使它在编译时没有抱怨。
| 归档时间: |
|
| 查看次数: |
15960 次 |
| 最近记录: |