简体   繁体   中英

NSTableView just like Finder

I still have a long way to go learning Cocoa. I'm trying to learn to code a Table view just like the finder where there is a small icon to the left of the file listing. #1 Its not clear to me if those are two columns in a row or if that type of operation is handled as 1 column.

If someone could point me to a good, easy to follow example, I would appreciate it. I was able to follow one example and I can drag and drop files onto the view but it only displays the [files lastPathComponent]. I wasn't sure how to add the icon.

You are going to have to subclass NSCell if you want this. Here is a good example:

NSCell Image and Text Sample

While yes you could do as sosborn suggests, however if you're already using OSX 10.7 Lion, you can now (and should!) use NSViews instead. And specifically you can subclass NSTableCellView.

Personally, I would watch the WWDC video titled "View Based NSTableView Basic to Advanced" available here: https://developer.apple.com/videos/wwdc/2011/

This also includes sample code that will get you going.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM