ViewForTableColumn does not start (but objectValueForTableColumn)

When creating a view-based table, it calls the objectValueForTableColumn function instead of viewForTableColumn .

I set the table view to "view based" in my settings. But still I can not get it to call the correct function. I looked at the implementation of the apple example (tableviewplayground), and at some points I even copied the IB insert and functions, still not making progress.

Relevant Code:

// Should run - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { return nil; } // Gets run -(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { return nil; } 

Two photos, not sure how useful they are, but still. http://imgur.com/a/ix34Q

+6
source share
1 answer

A few things to check:

  • Does your NSTableView have a delegate class that implements the NSTableViewDelegate protocol? (I ask because tableView:viewForTableColumn:row: is the delegate method, whereas tableView:objectValueForTableColumn:row: is the data source method.)

  • Are there any bindings set in IB? (You mention that you copied the tip from an existing project.) Check mainly for binding to the content binding of NSTableView and to the subviews provided (usually a text box.)

  • Do you implement the numberOfRowsInTableView: method from NSTableViewDataSource and return a nonzero integer value?

Finally, you can take a look at the chapter "Table Programming Guide" in the "Program-Oriented View-Based Table Presentation" in the documentation.

+16
source

Source: https://habr.com/ru/post/926045/


All Articles