How to increase line height in NSTableView based on text content?

How to increase the row height in an NSTableView based on the text Content.Row the height should be increased when there is more text, and the line should decrease when the text is deleted.

I implemented a textDidChange notification in my subclass of NSTableView, but I did not find any method that would increase the height of the line. setRowHeight NSTableView will increase the height of each row in the table view. I would like to have a variable row height. Maybe I have some sample code or any pointers to execute this.


I found the following link

http://cocoadev.com/forums/discussion/1851/calculating-row-heights

But I can not find any example on this !. Any example on this would be of great help to me!


Tried to implement the following deleagate

- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row

calculating the length of the string. Now I can increase the height of the line, but the height of the NSTextFieldCell is the same. How to increase the height of the text field when changing the height of the line.

+7
source share
2 answers

corbin dunn provided a solution :

  • fix your autoresistant / AutoLayout coinstraints so that the text appears in its container,
  • calculate line height -tableView:heightOfRow: using a custom NSTableCellView object.
+1
source

You can increase the height of the tableviewrow in the method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {} . Call [tableView reloadData] on textDidFinishEditing to reload the table.

-nine
source

All Articles