I have UIViewController with UIScrollView and two labels and a button inside it:
UIView
-UIScrollView
-UILabel
-UILabel
-UIButton
I need to align my UILabels and UIButton after each other dynamically, as every view can have different size. UILabels are okay, but my UIButton goes into the middle of my second UILabel
Here is my code:
self.header.text = event.title;
self.header.numberOfLines = 0;
CGFloat headerHeight = [event.title sizeWithFont:[UIFont fontWithName:@"Arial" size:20] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
self.header.frame = CGRectMake(19, 20, 280, headerHeight);
CGFloat positionY = 40 + [self.header.text sizeWithFont:[UIFont fontWithName:@"Arial" size:20] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
CGFloat descriptionHeight = [event.descr sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:UILineBreakModeWordWrap].height;
self.descr.frame = CGRectMake(19, positionY, 280, descriptionHeight);
self.descr.text = event.descr;
self.descr.numberOfLines = 0;
positionY = self.descr.frame.origin.y + self.descr.frame.size.height + 40;
buyButton.frame = CGRectMake(19, positionY, 72, 37);
scrollView.contentInset = UIEdgeInsetsMake(contentInset, 0, 0, 0);
[scrollView setContentSize:CGSizeMake(320, positionY+80)];
UIScrollView has flexible height autoresizing mask set in IB.
Here is how it looks:

Can anyone tell me what am I doing wrong?
UPDATE:
If I remove autoresizing mask for my UIScrollView – everything works okay
If your problem resolves itself by changing the autoresizing mask on the scroll view, be sure to check the autoresizing mask on your buttons and labels to make sure they all agree.