1
votes

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?

1
possible duplicate of NSTableView Row Height based on NSStrings - user557219

1 Answers

3
votes
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;