UIScrollView - need restrictions for position / width x, need restrictions for position / height y

I have a view hierarchy that looks like this (based on other answers and Apple's extended AutoLayout guide for working with UIScrollView):

enter image description here

ScrollView requires 2 steps :

  • Set limits for the position and size (frame) of the ScrollView: just like you do it with any other view.
  • Set limits on the size of the content . Make sure that there are limitations from ScrollView subviews affecting all edges (leading, trailing, upper and lower) of the ScrollView, if you do this in the interface builder, and not programmatically.

Step 1 worked fine, and this was the result:

enter image description here

enter image description here

No problem with the position and size as expected. I just need to determine the size of the content (content height and content width) in the Builder interface with Step 2 .

Now I add restrictions affecting all 4 edges of the ScrollView like this:

enter image description here

Suddenly, ScrollView no longer knows the position and size (frame).

enter image description here

I looked at other answers and followed various steps, but cannot solve this problem. Sorry, I can’t post screenshots of the storyboard due to privacy issues.

+4
source share
2

. 3 :

  • ,
  • ContentSize - ,

, 1. .

, , "" . ContentSize. , "".

, :

  • "".
  • - , 100 x 100
  • .

. , , , , , , ... 100 x 100, - ... , , - .

subview , , 100 x 800, , (), ... 800 .

: - , - , ( view contentSize).

, !

+3
  • , , , 0.

  • , , , , , 0.

  • , , " " "".

+1

Source: https://habr.com/ru/post/1677210/


All Articles