0

It appears to only happen if the line word-wraps onto the next line, but if I do something like a list where there's no word wrap, it displays the height properly (e.g.:

@"1<br/><br/>
2<br/><br/>
...
200"

That will display every line but this will cut off the line:

@"SUPER LONG LINE WITH A LOT OF TEXT and WRAPS TO THE NEXT LINE<br/><br/>
...
LAST LINE WONT BE VISIBLE BECAUSE THE HEIGHT IS OFF"

////// Here is where I am loading the cell height (if i adjust the height here, I can view the rest of the content): //////Class with the table//////

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self populateCell:tableView indexPath:indexPath];

    [cell setNeedsDisplay];
    [cell layoutIfNeeded];

[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height

//////Custom Cell class////

for (NSString *item in arrayOfRandomText) {

            NSString *newItem = [item stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
            [myAppendedStr appendString:[NSString stringWithFormat:@"%@<br/><br/>", newItem]];

}

   NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithData:[myAppendedStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];

    [attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,attrStr.length)];
    [attrStr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica Neue" size:14.0] range:NSMakeRange(0, attrStr.length)];

    self.myTxtView.attributedText = attrStr;
Tim Nuwin
  • 2,775
  • 2
  • 29
  • 63
  • Hey I'm deleting my answer. When you figure out the solution would you mind posting it? – Tobias May 21 '15 at 17:39
  • Yeah no problem, I will update it once I figure this out! – Tim Nuwin May 21 '15 at 17:39
  • is this what you need? http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights – rob180 May 21 '15 at 22:09

0 Answers0