Since 10.7 NSTableView supports custom views.
Just drag a custom view to a table column, update the subclass of the view and of you go.
However, if you use a delegate for your NSTableView and your class has an outlet to the NSTableView, then don't forget to implement
in addition to
That should save you hours of debugging and 10 minutes of reading the documentation.
The problem I am having is this:
I added a custom view to a NSTableView and its content, layout and required height are based on the objectValue. Calculating the required height is quite complex and the required code is placed within the custom view subclass rather than within the NSTableView delegate/datasource.
The data is correctly loaded and by calling
the height is correctly adjusted because
is called by the NSTableView.
When I change the datasource or the table contents, etc. I know I have to call reloadData and/or noteHeightOfRowsWithIndexesChanged to update the table and adjust the row heights.
However, when a NSTableView is loaded from a xib file, cocoa first sets the row heights and then loads the data. But after the data has been loaded for the first time, the row heights need to be updated. How can I force a reload?
I tried adding noteHeightOfRowsWithIndexesChanged to:
but that didn't work.
Any idea how to do this?
Just drag a custom view to a table column, update the subclass of the view and of you go.
However, if you use a delegate for your NSTableView and your class has an outlet to the NSTableView, then don't forget to implement
Code:
-(NSView *) tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row;
Code:
-(id) tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex;
That should save you hours of debugging and 10 minutes of reading the documentation.
The problem I am having is this:
I added a custom view to a NSTableView and its content, layout and required height are based on the objectValue. Calculating the required height is quite complex and the required code is placed within the custom view subclass rather than within the NSTableView delegate/datasource.
The data is correctly loaded and by calling
Code:
-(void) noteHeightOfRowsWithIndexesChanged:(NSIndexSet *)indexSet:
Code:
-(CGFloat) tableView:(NSTableView *)tableView
heightOfRow:(NSInteger)row
When I change the datasource or the table contents, etc. I know I have to call reloadData and/or noteHeightOfRowsWithIndexesChanged to update the table and adjust the row heights.
However, when a NSTableView is loaded from a xib file, cocoa first sets the row heights and then loads the data. But after the data has been loaded for the first time, the row heights need to be updated. How can I force a reload?
I tried adding noteHeightOfRowsWithIndexesChanged to:
Code:
-(void) awakeFromNib;
-(void) windowControllerDidLoadNib:(NSWindowController *)aController;
Any idea how to do this?