0

I'm seriously lost on this one.

Here's the shot:

enter image description here

The price on Tea's Tea Matcha... is being cut off. I simply cannot figure out why.

I'm using boundingRectWithSize:...

When I log the height of the label's frame after calling layoutIfNeeded, it's the height that it should be for each respective frame: the same height as boundingRect.size.height.

Also, when I log the text of the label, the price is in the log so it's not that either.

It's just this and a few other labels out of hundreds that are having this issue and I do not know why.

This is my code for setting the height of the label:

CGRect boundingRect = [self.nameLabel.attributedText boundingRectWithSize:CGSizeMake(self.frame.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil];

self.nameLabelHeightConstraint.constant = ceil(boundingRect.size.height);
[self layoutIfNeeded];

One thing I've noticed - if instead of calculating the height with boundingRect and setting it manually I use sizeToFit on the label, it has this same problem but if I scroll past the row and back to it, it's fixed and the price appears underneath.

Anyone know wtf is going on here?

Tony Friz
  • 883
  • 1
  • 10
  • 27

1 Answers1

0

I found I was able to fix the issue by changing the default height constraint constant. I lowered it significantly (it was large enough that it was touching the bottom of the Cell.xib view. I made it spaced closer to the view above it by 1 pixel, lowered the default height constraint constant in IB and changed the type from equals to greater than or equal to. These things combined (I'm not sure which if not all did it) seem to have fixed the problem.

Tony Friz
  • 883
  • 1
  • 10
  • 27