I'm running into an issue with autolayout and cannot seem to find an answer to something that should be simple to achieve.
I have the following view hierarchy:
-UIScrollview
-UIView
- UILabel
- UILabel
- UILabel
The leading/trailing constraints on the labels makes them taller on thinner devices (iPhone 4s vs iPhone 6).
In order to get the UIScrollview to work properly, I need to set the height constraint of the UIView inside of the UIScrollView to avoid an 'ambiguous height' warning.
But when running on an iPhone 4s, the UIView is not tall enough to hold its subviews.
My only solution so far is to create a reference to the height constraint on the UIView and update the height constraint when the view appears:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
self.contentHeight.constant =self.lastLabel.frame.origin.y+ self.lastLabel.frame.size.height;
[self.view layoutIfNeeded];
}
I would think there has to be a better way to do something that is so simple.
I've attached an image to show the issue in detail.
Thank you for your time.
Per @Katty below, making the width/height equal to the scrollview's superview results in bigger issues: