This is my UICollectionViewCell
image...
I am added the autolayout constraints to this cell...but it gives me lots of breaking constraints error....Then I decided to go step by step to resolve the braking constraints error.so I just give the constraints to UIImageView and title label, and the console log is....
(
"<NSLayoutConstraint:0x158cec50 H:[UIImageView:0x158de490(100)]>",
"<NSLayoutConstraint:0x1582bd30 H:|-(8)-[UIImageView:0x158de490] (Names: '|':UIView:0x158db340 )>",
"<NSLayoutConstraint:0x1582bd90 H:[UILabel:0x158de540'Rhythm | Responsive Multi...']-(8)-| (Names: '|':UIView:0x158db340 )>",
"<NSLayoutConstraint:0x1582b200 H:[UIImageView:0x158de490]-(7)-[UILabel:0x158de540'Rhythm | Responsive Multi...']>",
"<NSLayoutConstraint:0x15800a00 H:[UIView:0x158db340]-(0)-| (Names: '|':UIView:0x158cea10 )>",
"<NSLayoutConstraint:0x15800a60 H:|-(0)-[UIView:0x158db340] (Names: '|':UIView:0x158cea10 )>",
"<NSAutoresizingMaskLayoutConstraint:0x147cfe50 h=--& v=--& H:[UIView:0x158cea10(50)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x158cec50 H:[UIImageView:0x158de490(100)]>
Here is my UIImageView constraints and my title label constraint
I want my UIImageview width is 100..so when I just added above constraints for image...its fine but as soon as I added leading constraint of label...it causes problem...and I want label width dynamic
SO, how can I resolve this errors...
EDIT
My view hierarchy
-Cell
- View
- Image
- Title
SOLVED
This 2 lines solved the issue....
cell.contentView.frame = cell.bounds
cell.contentView.autoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin
CURIOUS ABOUT
But I want to know why is it so....because in some project with same layout and same constraints, its working fine and in some its not...WHY???
place the constraints as below screen shots