Search code examples
iosswiftuiscrollviewxcode6autolayout

UIScrollView auto layout not working the width of contentView


i'm back developing IOS after a year and a half. I'm really having difficulty in make use of UIScrollView and auto layout.

I'm developing an application running just in Iphone and portrait orientation.

I have a simple form inside my content view...

  • label
  • textField
  • textField
  • textField
  • textField
  • button
  • textField
  • view
    • imageView
    • label

The problem is with the width of the contentView's content. The size is been defined for the labels. I would like (And really have to do) o size it according with the screen size.

Here is my constraints of my first text field: enter image description here

Here is my simulator screen running the app: enter image description here

how I mentioned before, it seems to get the size according the label and not according the screen size. If I create a constraint of size for the first label, this size change but I would like to get the size dinamically based on screen.

I didn't write any code, I want to do it preferentially using auto layout to understand the concepts of auto layout better.

If someone could help me to solve it... I would be very grateful.


Solution

  • Pin your contentView.width equal to scrollview.width.