52

I am making a very basic UIScrollView test. Here is my setup enter image description here It shows me the following AutoLayout error:

ScrollView has ambiguous scrollable content height 
Jonathan Soifer
  • 2,715
  • 6
  • 27
  • 50
Madu
  • 4,849
  • 9
  • 44
  • 78

1 Answers1

113

You need to ensure you've got a chain of vertical spacing constraints from the top of the scroll view through all your elements to the bottom of the scroll view.

Once you do that, your warning/error should go away.

Sandy Chapman
  • 11,133
  • 3
  • 58
  • 67
  • 1
    I have given a height to the scrollview. Will it work? Or do i need to add bottom guide as well ? – Abdul Yasin Jan 27 '15 at 06:46
  • 5
    @AbdulYasin, no, you need the content within the scrollview to have a defined height as well. The height of the content in the scrollview can be larger or smaller than the height of the scrollview itself. – Sandy Chapman Jan 27 '15 at 11:54
  • But then how scrollView will scroll if we set if frame equal to its contentsize?? – Developer Dec 18 '15 at 13:25
  • 1
    @Developer the scrollview's frame does not equal the size of the scrollview's content. If they were equal, then the scrollview would never scroll. – Sandy Chapman Dec 18 '15 at 14:15