Emirhan acısu
Emirhan acısu

Reputation: 25

Multiline UILabel in uicollectionViewCell wrong height

I insert a multi-line label inside the cell, the cell is not sized correctly. When I use it as a single line label, it's fine, but when I use multiple, the height is wrong. Even though I used SizeToFit() I couldn't find the solution. I need to use Cell i automatic size. When I scroll, the problem is fixed, but there is wrong on the first boot. Any suggestions what can I do?

wrong cell state after scrolling

Upvotes: 1

Views: 559

Answers (2)

Emirhan acısu
Emirhan acısu

Reputation: 25

The problem was solved, I needed to add a contentView inside the cell and set translatesAutoresizingMaskIntoConstraints to false. Thanks for answers

Upvotes: 1

Alirza Eram
Alirza Eram

Reputation: 178

try this:

let layout = UICollectionViewFlowLayout()
layout.estimatedItemSize = UICollectionViewFlowLayout.automaticSize

also, make sure to align all UILabel edges to cell.contentView.

Upvotes: 0

Related Questions