UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Is there an update for this .frame(maxWidth: .infinity)?

Forums > SwiftUI

Is there an update for this .frame(maxWidth: .infinity)?

Please see error message below, for it did not show on Tutorial. The item in question, is that I will have use for .frame(maxWidth: infinity) late on this week.

https://www.hackingwithswift.com/books/ios-swiftui/how-scrollview-lets-us-work-with-scrolling-data Why am I getting a alert for this (

struct ContentView: View {
    var body: some View {
        ScrollView(.vertical) {
            VStack(spacing: 10) {
                ForEach(0..<100) {
                    Text("item \($0)")
                }
            }
            .frame(maxWidth: .infinity) 
            // ????SwiftUI: Invalid frame dimension (negative or non-finite).
        }
    }
}

2      

Replace .infinity with nil. It will take the respective width/height value of the previous view.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.