I've been trying to build the following view that I already built in an Android app:
I used a stack view to layout the views vertically. There is a label, followed by first table view, then another label, then another table view(Android configuration is the same):
What I would expect is to have the first table view stretch to accomodate the 3 items inside, the label after it to follow, and so on without constraining heights.
This is how the autolayout looks like:
And these are the constraints I set up:
How can I achieve the same view like in Android?
The problem is that views based on UIScrollView (all table views and collection views are) don't have an intrinsic size to return to the Stack View; they could theoretically be of infinite size. The correct way to solve this is not to put them in a stack view, but add them as constrained sub-views with the following constraints:
That will force the table views to each use half of the available screen space, while remaining flexible for different screen sizes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.