Reputation: 77
Whenever I try and change a labels text with
_levelNumberLabel.text = [NSString stringWithFormat:@"%i", difficulty];
it keeps moving all my labels, images and buttons back to their original location. I have never had this problem before, and I know its this line of code because it doesnt happen when I delete it. Any ideas?
Upvotes: 0
Views: 220
Reputation: 535606
The problem is that you're using auto layout and you've moved your interface around by setting the frame
of your labels, images, and buttons. But frame
and auto layout are opposites. Since you are using auto layout, you should have changed the constraints of your labels, images, and buttons.
So what's happening now is that you're setting the text of a label and this in turn is causing layout to happen. Layout, when auto layout is involved, means obeying the constraints. You didn't change the constraints, so, just as you say, this means that everything goes back to its original position - because that is what your constraints say to do.
Upvotes: 1