MacOS NSTableView

from china: Why can't I ask in Chinese!!!!

The idea I started: I created an NSTableView in xib that does not contain any columns, because I want NSTableView to dynamically display the column and table content based on my content.

The nightmare began!

Immediately after the code created two columns, Name and Age, addTableColumn no problem, can be displayed.

Then I want to create each Cell and display it.

In xib, there is a content mode attribute in NSTableView, which is Cell Based by default. Since only one TableView was created at the beginning, it has been unsuccessful to change to View Based in this case. It may be because of this reason that the following is incorrect!

Then in the delegate, start to create Cell, try to create NSTextFiled or NSTableCellView through makeView unsuccessful, always return nil. But if there is no problem creating an NSTextFiled directly, it can be created successfully, and the data can be displayed in the table, but if you create an NSTableCellView directly, and then return, it will still be unsuccessful!

Then change another way of thinking, add two columns and cells to the NSTableView in xib, then set the id to Name and Age, then the content mode will automatically change to View Based, and then use the makeView operation, everything is okay!

Question: Is makeView only available in View If it is used in Based mode, Cell Based cannot be used? That is, NSTableCellView can only be used in View Based? That is, the column and cell details must be defined in the xib before it can be used? If so, it is depressing!

If you customize the xib, create a subclass that inherits NSTableCellView, and then makeView does not know whether it will work, it is estimated that it will not work!

 

MacOS NSTableView
 
 
Q