To turn off refreshable in a nested view that is displayed as a sheet or full screen cover in SwiftUI, you can use the following code:
.sheet(isPresented: $showSheet) {
NestedView()
.onAppear {
UIScrollView.appearance().isRefreshingEnabled = false
}
.onDisappear {
UIScrollView.appearance().isRefreshingEnabled = true
}
}
In this code, NestedView
is the view that contains the scroll view with the refreshable content. The onAppear
and onDisappear
modifiers are used to set the isRefreshingEnabled
property of the UIScrollView.appearance()
instance to false
when the sheet is presented and to true
when it is dismissed. This will disable the refresh control for the nested view when the sheet or full screen cover is displayed, and enable it again when the view is dismissed.
Asked: 2023-03-26 11:00:00 +0000
Seen: 11 times
Last updated: Sep 16 '21