加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 为我的应用程序的文档类型注册一个图标

发布时间:2020-12-16 03:33:13 所属栏目:百科 来源:网络整理
导读:我正在尝试为我的应用程序的文档类型注册一个图标.在阅读了 Declaring New Uniform Type Identifiers并查看/ Developer / Examples / Sketch后,我在Info.plist中找到了类似的内容: keyCFBundleDocumentTypes/keyarray dict keyCFBundleTypeRole/key stringV
我正在尝试为我的应用程序的文档类型注册一个图标.在阅读了 Declaring New Uniform Type Identifiers并查看/ Developer / Examples / Sketch后,我在Info.plist中找到了类似的内容:
<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSItemContentTypes</key>
    <array>
      <string>com.mycompany.myextension</string>
    </array>
    <key>NSDocumentClass</key>
    <string>NSString</string>
  </dict>
</array>

...

<key>UTExportedTypeDeclarations</key>
<array>
  <dict>
    <key>UTTypeDescription</key>
    <string>Blah blah blah</string>
    <key>UTTypeConformsTo</key>
    <array>
      <string>public.data</string>
    </array>
    <key>UTTypeIconFile</key>
    <string>My-file-icon.icns</string>
    <key>UTTypeIdentifier</key>
    <string>com.mycompany.myextension</string>
    <key>UTTypeTagSpecification</key>
    <dict>
      <key>public.filename-extension</key>
      <array>
        <string>myextension</string>
      </array>
    </dict>
  </dict>
</array>

现在,一切都很好,花花公子,即当我点击带有我的扩展名的文件等时我的程序被打开.但是,文档图标没有在操作系统中注册,即我看到一个丑陋的空白图标而不是我漂亮的My-文件icon.icns.我怀疑我在上面的plist中遗漏了什么,有什么想法吗?

解决方法

尝试将图标名称放在CFBundleDocumentTypes数组中的CFBundleTypeIconFile键中,而不是放在UTExportedTypeDeclarations数组中.

当然,请确保“My-file-icon.icns”位于目标的Copy Bundle Resources构建阶段,并被复制到应用程序包中的Contents / Resources中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读