ScrollView auto layout

      UIScrollView automatic layout has always been a headache for beginners, and the "Has ambiguous scrollable content height" problem often occurs. Because it is different from other Views, it has a contentsize. When using manual layout, this property is generally set manually. But auto layout requires constraints.

Here is a small example:

Some text content needs to be placed in UIScrollView. Since the text content is dynamic, considering the compatible display of different sizes and models , it needs to be displayed in scrolling form.

Here, I put a View into UIScrollView, and the content displayed in it is placed in the View. For details see:

UIScrollView constraint graph:



 

UIView constraint graph:



 

Note the red mark. The 150 marked down is equivalent to setting the contentsize.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326654779&siteId=291194637