Avatar ·

UIScrollView scrollable content size ambiguity in Auto Layout

Hi everyone! I'm new to Swift and can't figure out UIScrollView in Interface Builder. I'm using Auto Layout, but Xcode keeps giving me an error: "Scrollable Content Size Ambiguity". The problem is that I don't understand how to properly set the content size so that ScrollView works correctly.\n\nHere's what I'm doing: I add a UIScrollView to the ViewController, pin it to the edges (leading, trailing, top, bottom) using constraints to the Safe Area. Inside the ScrollView, I put a UIView (contentView), to which I add labels, images, and buttons. I also pin the contentView to all four sides of the ScrollView. But Xcode complains that the ScrollView doesn't know what its content is.\n\nI tried adding a fixed height for the contentView, but then the app doesn't scroll if the content is smaller than the screen.