1

I want to display a string inside a tableview that can be ( max ) 4000 characters long. I have tried using NSAttributedString to find out the row height for the NSTextFieldCell, but I always fall a bit short when I insert > 4 lines of text.

The NSTextFieldCell is set to using NSLineBreakByWrapping for its line breaks.

What next to NSAttributedString can I use to get the height I need?

Charles
  • 50,943
  • 13
  • 104
  • 142
Antwan van Houdt
  • 6,989
  • 1
  • 29
  • 52
  • possible duplicate of [NSTableView Row Height based on NSStrings](http://stackoverflow.com/questions/3212279/nstableview-row-height-based-on-nsstrings) –  Nov 30 '11 at 22:51

1 Answers1

3
id cell = [[tableView tableColumnWithIdentifier:@"test"] dataCell];
    [(NSTextFieldCell *)cell setStringValue:[_messages objectAtIndex:row]];
    NSRect tallRect = NSMakeRect(0, 0, [tableView frame].size.width, CGFLOAT_MAX);
    return [cell cellSizeForBounds:tallRect].height;
Antwan van Houdt
  • 6,989
  • 1
  • 29
  • 52