EDIT: The question was not answered by the linked reply. I'm still stuck on this...
I've got a table that I use for chat messages. Each message is a variably-sized box including some text. I want the row height in my table to dynamically change depending on the size of the message box.
If I tick 'automatic' for size style in IB, it makes all of the rows have tiny heights. It looks like iOS have UITableViewAutomaticDimension which automatically scales the table, but I can't find anything like that for NSTableView.
I know there's an option to create the following function:
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat
{
return 50 // ????
}
and I am able to set the row height using that (the above sets all of my rows to height 50), but I don't know how to make it dependent on the size of the text in my box. How can I do this efficiently?
Here's one solution
First you set up a NSTextfield in code. This is a "virtual" field in as it is never actually drawn
Then in the heightOfRow function
more details and NSTextfield extensions can be found Here. Note this answer is in Swift 2.3 (haven't made the plunge to 3 yet)