Lack of x limit and height on UIScrollView at autorun

Disclaimer: I saw an SO method that involves adding a UIView (called contentView) to a UIScrollView and putting all that content. I do not want to use this technique, as I would like to understand why I have a current problem.

I have a UIScrollView by UIView by default, the UIViewController, its UIScrollView has 4 limitations: one on each side (trailing, top, lead, bottom) so that it binds the parent to the UIView. It works!

UIScrollView working limitations

But when I want to add a UIImageView to a UIScrollView, and I want it to be glued to its parent sides (end, top, leader) + specific height, now I have a problem.

Broken UIImageView Constraints

It says:

Scroll View: Has ambiguous scrollable height
Scroll View: Needs constraints for: X position or width
+4
3

, xcode , , UIScrollView UIImageView .

UIScrollView, , xcode, . , UIImageView, UIScrollView, xcode, UIScrollView. , UIScrollView - .

, , , . - . .

: , IB. , , . IB, answer . UIImageView. , xcode UIScrollView, .

+6

, :  1. . Superview  2. Scrollview UIView. Superview UIView. , . .

+2

.

:

  • , 0,0 .
  • , top = 0, left = 0, right = 0, bottom = 0.
  • , .

, scrollview x.

0
source

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


All Articles