Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIStackView inside UICollectionViewCell autolayout issues after running on Xcode 10 beta

My stack view contains an image and label to display some tasks. They were all left aligned on multiple rows.

I didn't have any issue running on Xcode 9, but when I run on Xcode 10 beta 6, I get some autolayout issues, I always get errors like for the stack view:

Need constraint for X position
Need constraint for Y position

My current constraints for stack view are:

Leading edge to cell - 5
Trailing edge to cell - 5
Bottom edge to cell - 2
Top edge to cell - 2

So I don't see what changed to complain about this, for me it's obvious that I have the X and Y set already.

Here is two screenshots with how it looks when it runs (label is truncated) and the storyboard:

enter image description here

enter image description here

like image 342
Adrian Avatar asked Aug 26 '18 08:08

Adrian


1 Answers

Embed your Stack View in a UIView. Also give the view constraints relative to UICollectionViewCell to make it behave like ContentView in UITableViewCell.

like image 87
Jeet Gandhi Avatar answered Nov 10 '22 03:11

Jeet Gandhi