Tobias Bauer
Tobias Bauer

Reputation: 131

UIScrollView always snaps back to center

I have I vertical ScrollView in SwiftUI when I add "normal" Components then I can scroll normal but when I add a Component which gets the data from a websocket only the Content in the middle it is scrollable and the Content at the top and the bottom always snaps back to the middle

struct HomeView : View {
    @EnvironmentObject var socketData: Socket
    var body: some View {
        ScrollView(.vertical, showsIndicators: false) {
            VStack {
                Text(String(socketData.message))
                LiveStats()
                LiveStats()
                LiveStats()
                LiveStats()
                LiveStats()
                Weather() //This is the View which gets the data async
            }
        }
    }
}

Upvotes: 2

Views: 574

Answers (1)

Tobias Bauer
Tobias Bauer

Reputation: 131

I fixed the problem by applying a frame to the Weather struct but I don't know how to fix the problem when I don't have a certain height.

Upvotes: 2

Related Questions