1

I have a UIContainerView that its embedded UIViewController contains a UILAbel and two UIButton. The UILabel text has a dynamic number of lines and it expands according to the number of it's number of lines. What I'm asking for is how to make the UIContainerView expands to fit the new embedded label size?

I am using autolayout constraints to manage the label height.

Ismail
  • 2,778
  • 2
  • 24
  • 39

1 Answers1

0
UIContainerView *view;
.....
label.text = @"Some text";
[label sizeToFit];

CGRect viewFrame = view.frame;
viewFrame.size = label.frame.size;
view.frame = viewFrame;
gaRik
  • 607
  • 6
  • 10
  • I'm using `autolayout constraints`. Is there any way to handle it the same way without setting the frame size? – Ismail Apr 17 '15 at 15:23
  • You need set correct auto layout settings of parent view. Look at http://stackoverflow.com/questions/13051617/how-to-resize-a-parent-view-based-on-the-size-of-subviews-layouted-with-autolayo – gaRik Apr 17 '15 at 15:34