Q:

Dynamic UILabel height inside UIScrollView with Autolayout

I am using autolayout with UIScrollView to show some attributes from an object. I download this information dinamically from web service. The scrollview has a constant width (because I don't want to have a vertical scroll behavior) and its subviews respect this width with a group of constraints, but I can't to increase the UILabel's height dynamically.
I code everything and I use viewDidLoad selector to create subviews...
- (void)viewDidLoad {
    [super viewDidLoad];
    .
    .
    .

    UILabel *descriptionLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO;
    descriptionLabel.numberOfLines = 0;
    descriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
    descriptionLabel.opaque = YES;
    descriptionLabel.backgroundColor = [UIColor clearColor];
    descriptionLabel.textColor = [UIColor whiteColor];
    descriptionLabel.textAlignment = NSTextAlignmentRight;
    descriptionLabel.font = [UIFont appetitoMediumItalicFontWithSize:15.0f];
    descriptionLabel.text = NSLocalizedStringFromTable(@"APT_DISH_DETAIL_DESCRIPTION", @"DishDetail", @"Etiqueta que contiene la descripción del platillo");
    [descriptionLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [self.detailContentScrollView addSubview:descriptionLabel];
    self.descriptionLabelS = descriptionLabel;

    .
    .
    .
}

You can watch the self.detailContentScrollView variable, this is an IBOulet created from view controller's nib.
Then I use the updateConstraints selector...
- (void)updateConstraints {
[super updateConstraints];
// This dictionary has more variables, ok
NSDictionary *viewsDict = @{@"dish_description_label": self.descriptionLabelS};
.
.
.

[self.descriptionLabelS setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
[self.detailContentScrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view1][dish_description_label]-[view2][view3][view4]-|" options:0 metrics:nil views:viewsDict]];

.
.
.
}

and finally, when I receive the web service's info, I send sizeToFit's UILabel selector and layoutIfNeeded from the scrollview. But my UILabel never resizes itself with the new content. What am I doing wrong?

A:

UIScrollView content size is updated dynamically with autolayout, maybe you only must do the following
- (void) setupScroll
{
    [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [_contentView setTranslatesAutoresizingMaskIntoConstraints:NO];

    [_scrollView addSubview:_contentView];

    NSArray *horizontal = [NSLayoutConstraint constraintsWithVisualFormat:@"|[_contentView]|"
                                                                  options:0
                                                                  metrics:nil
                                                                    views:NSDictionaryOfVariableBindings(_contentView)];
    NSArray *vertical = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_contentView]|"
                                                                options:0
                                                                metrics:nil
                                                                  views:NSDictionaryOfVariableBindings(_contentView)];

    [_scrollView addConstraints:horizontal];
    [_scrollView addConstraints:vertical];

    UIView *mainView = self.view;
    horizontal = [NSLayoutConstraint constraintsWithVisualFormat:@"|[_contentView(==mainView)]|"
                                                         options:0
                                                         metrics:nil
                                                           views:NSDictionaryOfVariableBindings(_contentView, mainView)];

    [mainView addConstraints:horizontal];
}

Where _contentView is your UILabel (If you have a more complex view hierarchy put on a view container) and self.view is the controller view (or anything else). Hope this helps also: iOS Autolayout with UIScrollview: Why does content view of scroll view not fill the scroll view?....
Also don't forget to establish your UILabel preferredMaxLayoutWidth 
Cheers!

A:

If you want to make it with views:

Add a UIScrollview with a constraint height >= [minimum value you want] e.g. 480
Add a UILabel to the scrollview with a height constraint >= [minimum value you wan] e.g. 460

Like in the following images:

if you need to make it programmatically

UIScrollView *scrollView= [UIScrollView new];
    scrollView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:scrollView];

    UILabel *scrollViewLabel = [[UILabel alloc] init];
    scrollViewLabel.numberOfLines = 0;
    scrollViewLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [scrollView addSubview:scrollViewLabel];

    scrollViewLabel.text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ac urna ac ipsum sodales fermentum ornare quis tellus. Integer urna dolor, placerat ut pharetra sit amet, mattis a eros. Maecenas dapibus accumsan felis eget faucibus. Nulla rhoncus gravida neque, sed suscipit ex tempor quis. In sagittis sed enim ut posuere. Donec varius euismod rutrum. Pellentesque mauris sem, mollis id odio eu, maximus interdum elit. Mauris pharetra magna ut tortor lobortis sollicitudin. Cras volutpat porta facilisis. Praesent lacinia mi at volutpat accumsan. Sed eu cursus metus. Donec a convallis nunc. Curabitur tempus accumsan lacus vitae luctus. Sed non quam non leo condimentum congue. Nam dui ipsum, elementum in congue id, mollis ac mauris. Morbi finibus turpis quam, ut venenatis magna malesuada ac. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam erat volutpat. Curabitur nulla mi, aliquam faucibus blandit et, maximus eu libero. Duis semper, est posuere egestas interdum, quam nibh convallis odio, efficitur tempor purus arcu quis justo. Donec euismod feugiat urna in viverra. Sed vel tristique massa. Morbi in consequat sem. Nunc placerat lacus a mauris tempus porttitor. Fusce sed iaculis tortor, nec luctus ligula. Donec euismod metus mauris. Mauris sit amet euismod sapien. Praesent lobortis interdum ligula consequat viverra. Quisque et tortor mattis, congue dolor a, sagittis ligula. Phasellus in lacinia magna. Fusce vel placerat nisi. Maecenas egestas mattis lorem, vel tincidunt mauris eleifend et. In eu pulvinar nibh. Suspendisse ac suscipit orci. Suspendisse at lectus vel purus hendrerit lacinia at posuere sapien. Nunc auctor nisi eget nunc suscipit auctor. Donec fringilla odio lectus, quis porttitor nisl fermentum eget. Nam nunc purus, lobortis id sem porta, accumsan egestas quam. Integer blandit feugiat nunc ac scelerisque. Pellentesque vehicula, massa eget mollis aliquam, felis nulla posuere elit, at gravida elit diam id ligula. Suspendisse pharetra velit sed lacus scelerisque viverra. Maecenas volutpat non metus a interdum. In vitae vestibulum enim. Proin vitae libero non odio finibus pulvinar. In condimentum, sapien ac vehicula lobortis, dolor magna iaculis ex, in consectetur turpis orci eget justo. Suspendisse in lobortis justo, bibendum finibus lorem. Suspendisse ullamcorper diam eu elit sollicitudin, at tempus massa dignissim. In a ante rhoncus, porttitor tortor fermentum, molestie nunc. Phasellus mi dolor, vehicula sed sodales ut, sollicitudin ac ex. Praesent consequat, nunc sed posuere condimentum, risus ex malesuada nulla, sed faucibus velit elit ac risus. Ut venenatis ut nisl in hendrerit.";


    /*** Auto Layout ***/

    NSDictionary *views = NSDictionaryOfVariableBindings(scrollView, scrollViewLabel);

    NSArray *scrollViewLabelConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[scrollViewLabel(scrollView)]" options:0 metrics:nil views:views];
    [scrollView addConstraints:scrollViewLabelConstraints];

    scrollViewLabelConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[scrollViewLabel]|" options:0 metrics:nil views:views];
    [scrollView addConstraints:scrollViewLabelConstraints];

    NSArray *scrollViewConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[scrollView]-|" options:0 metrics:nil views:views];
    [self.view addConstraints:scrollViewConstraints];

    scrollViewConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[scrollView]-|" options:0 metrics:nil views:views];
    [self.view addConstraints:scrollViewConstraints];

