OSX自定义扩展图标关联 [英] OSX Custom extension icon Association

查看:165
本文介绍了OSX自定义扩展图标关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码让我的应用程序显示自定义文件扩展名的图标:

I'm trying to get my application to display an icon for a custom file extension using the following code:

<key>CFBundleDocumentTypes</key>
   <array>
       <dict>
           <key>CFBundleTypeName</key>
           <string>My Custom Extension</string>
           <key>CFBundleTypeRole</key>
           <string>Viewer</string>
           <key>LSItemContentTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
           <key>LSHandlerRank</key>
           <string>Owner</string>
           <key>NSExportableTypes</key>
           <array>
                   <string>com.myapp.myext</string>
           </array>
       </dict>
    </array>
   <key>UTExportedTypeDeclarations</key>
   <array>
           <dict>
                   <key>UTTypeIconFile</key>
                   <string>Myicon.icns</string>
                   <key>UTTypeDescription</key>
                   <string>My Custom Extension</string>
                   <key>UTTypeConformsTo</key>
                   <array>
                           <string>public.data</string>
                   </array>
                   <key>UTTypeIdentifier</key>
                   <string>com.myapp.myext</string>
                   <key>UTTypeReferenceURL</key>
                   <string>http://www.myapp.com</string>
                   <key>UTTypeTagSpecification</key>
                   <dict>
                           <key>public.filename-extension</key>
                           <array>
                                   <string>myext</string>
                           </array>
                   </dict>
           </dict>
   </array>

我尝试过使用 UTTypeIconFile AND CFBundleTypeIconFile ,图标出现在应用程序包内的我的Content / Resources文件夹下,但在查看具有我的文件扩展名的文件时,我仍然看到一个空白图标

I've tried using both UTTypeIconFile AND CFBundleTypeIconFile, and the icon is present under my Content/Resources folder inside the app bundle, but I still see a blank icon when looking at files that have my file extension

我不确定它是否重要,但是这个应用程序是使用 JavaApplicationStub (它是一个java应用程序)启动的

I'm not sure if it matters, but this application is launched using the JavaApplicationStub (it's a java app)

任何帮助将不胜感激:)

Any help would be appreciated :)

推荐答案

我通过使用 JavaApplicationStub 。您是否尝试使用Apple的 .app /About/About.htmlrel =nofollow> Jar Bundler ?您应该可以注册您的文件类型App支持

I read about some problems by using just the JavaApplicationStub. Did you try to build an .app with Apple's Jar Bundler? You should be able to Registering the File Types Your App Supports.

这篇关于OSX自定义扩展图标关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆