I have an view:

There is layout constraint between label1 and label2. Pressing on button adds text from text view to label1. After it label 1 is resized to fit text (sizeToFit is called). And after resizing it looks like constraints don’t work:

Does somebody has an idea how to make constraints work?
My coode:
@interface ViewController ()
{
CGFloat _width;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void) viewDidAppear:(BOOL)animated
{
_width = self.l1.frame.size.width;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)addText:(id)sender {
self.l1.text = [NSString stringWithFormat:@"%@ %@", self.l1.text, self.text.text];
self.l1.frame = CGRectMake(self.l1.frame.origin.x, self.l1.frame.origin.y, _width, 0);
[self.l1 sizeToFit];
}
@end
I’ve found the reason: height constraint was equal to 40 of label 1. When I change it to greater or equal , all other constraints work ok.