问题
What I'm trying to do is have a page similar to following wireframe that all UILabel
s height should dynamically change based on the text:
I currently have a UIView
inside a UIScrollView
. The issue is I can't get the UIView
resize properly based on the its content, for example when description is long. The sample code can be downloaded from here
If not into the mood for code, here's the constraints and how it's setup:
I tried to use the approach mentioned in this post
回答1:
FINALLY, found the solution to it. Needed to remove any height constraint for UIScrollView
and contentView
and add a bottom constraint as shown below:
Updated the sample app with this change. Now the sample app works as expected.
来源:https://stackoverflow.com/questions/45395920/uiview-with-auto-layout-doesnt-increase-height-inside-uiscrollview