ios - Multiline label in collection view cell breaks after reuse -


i have custom uicollectionviewcell several ui elements, laid out using autolayout setup in code.

on larger devices (iphone 6 , up) works expected.

on smaller devices however, multiline uilabel breaks, (it seems) after reuse.

on initial display, first cell looks this:

initial display of cell

after cell has been scrolled off screen , brought on again, looks this:

second display of cell

these constraints set on label:

    descriptionlabel.centerxanchor.constraint(equalto: firstbutton.centerxanchor),     descriptionlabel.leadinganchor.constraint(equalto: otherlabel.leadinganchor),     descriptionlabel.topanchor.constraint(equalto: firstbutton.bottomanchor, constant: 15),     secondbutton.topanchor.constraint(greaterthanorequalto: descriptionlabel.bottomanchor, constant: 20), 

i feel it's greaterthanorequalto constraint, if replace plain old equalto constraint, layout goes wild , label shrinks down fit 1 line.

i've faced similar problem in uicollectionview , found solution in preferredmaxlayoutwidth property , widthanchor

productnamelabel.widthanchor.constraint(equalto: self.widthanchor, multiplier: 0.6) productnamelabel.preferredmaxlayoutwidth = self.frame.size.width * 0.6 

it should fix problem.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -