如何在 OS X 10.5 和 10.6 上获取通用文件夹图标的 NSImage

发布于 2024-08-05 12:46:11 字数 623 浏览 3 评论 0原文

我正在编写一个 Cocoa 应用程序,它在 NSOutlineView。我为 NSBrowserCell 提供了一个自定义图标在大纲列中,它工作得很好,但我遇到了一个小障碍 - 使用 [NSImage imageNamed:@"NSFolder"] 返回正确的图像(通用文件夹icon) 在 10.6 上,但在 10.5 上它返回 nil,因此所有文件夹图标都会消失。 (我找不到任何有关 NSFolder 图标名称的文档来查看它何时引入 - 我通过反复试验才使其工作。)

是否有一种未弃用的方法来获取适用于 10.5 和 10.6 的通用文件夹图标?

I'm writing a Cocoa application that displays the contents of an archive file in an NSOutlineView. I provide a custom icon for an NSBrowserCell in the outline column, and it works great, but I ran into a little snag — using [NSImage imageNamed:@"NSFolder"] returns the correct image (a generic folder icon) on 10.6, but on 10.5 it returns nil, so all the folder icons disappear. (I can't find any documentation on the NSFolder icon name to see when it was introduced — I got it working by trial and error.)

Is there a non-deprecated method for getting a generic folder icon that works on both 10.5 and 10.6?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2024-08-12 12:46:11

[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)]

(我认为)

[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)]

(I think)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文