7

How to increase the row height in a NSTableView based on the text Content.Row height should be increased when there is more text and the row should shrink when the text is deleted.

I implemented the textDidChange notification in my subclass of NSTableView,but I did not find any method which will increase the row height. setRowHeight of NSTableView will increase the height of every row in the tableview. I would like to a variable row height.Can I have any sample code or any pointers to accomplish this.


I found the following link

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

But I am not able to find any example on this!. Any example on this would be a great help for me!


Tried to implement the following deleagate

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

by calculating the string length,Now I am able to increase the row height ,but the NSTextFieldCell height is same. How can I increase the height of the textfield when the row height changes.

Ram
  • 1,872
  • 5
  • 31
  • 54

2 Answers2

1

corbin dunn gave a solution:

  • fix your autoresizing/AutoLayout coinstraints so the text view sticks to its container,
  • calculate the row height -tableView:heightOfRow: with the help of a custom NSTableCellView object.
Community
  • 1
  • 1
ctietze
  • 2,805
  • 25
  • 46
-9

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

utsabiem
  • 920
  • 4
  • 10
  • 21