AliSoftware/OHAttributedLabel — Issue #51: One-line text disappears inside UITableView
Author: AndreyChernyh
Created: 2011-11-29 12:56:36+00:00
State: open

Hello,

My app is using OHAttributedLabel in UITableView. I am loading my cell from XIB which has OHAttributedLabel.

```objective-c
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"ImageCommentCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
OHAttributedLabel *commentLabel;
CGRect labelFrame;

if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"ImageCommentCell" owner:self options:nil];
cell = _imageCommentCell;
_imageCommentCell = nil;
}

commentLabel = (OHAttributedLabel *)[cell viewWithTag:2];
labelFrame = commentLabel.frame;
labelFrame.size.height = 18;
commentLabel.frame = labelFrame;
commentLabel.attributedText = [NSAttributedString attributedStringWithString:@"test"];
[commentLabel setNeedsDisplay];

return cell;
}
```

My table loads fine initially (with "test" text in each cell). But when I scroll up and down the "test" text suddenly disappears in some cells. If I comment out the following code then everything works fine:

```objective-c
labelFrame = commentLabel.frame;
labelFrame.size.height = 18;
commentLabel.frame = labelFrame;
```

But I still need a way to setup the height dynamically for each label (depending on the size of text).

Thanks,
Andrey