Ask Your Question
1

What is the method for turning off refreshable in a nested view that is displayed as a sheet or full screen cover in SwiftUI?

asked 2023-03-26 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-09-16 22:00:00 +0000

djk gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-26 11:00:00 +0000

Seen: 11 times

Last updated: Sep 16 '21