2013-04-05 144 views
3

我試圖將文件類型與我的應用程序相關聯(pdf和doc)。 對於pdf,沒關係。我讀了這個主題:How do I associate file types with an iPhone application?將文件類型與我的應用程序(pdf和doc)相關聯

它的作品完美。但我試圖添加.doc類型,但它不起作用。

編輯:它的工作原理與此代碼(PDF,Word和Excel):

這裏是我的應用程序-的info.plist:

<key>CFBundleDocumentTypes</key> 
<array> 
    <dict> 
     <key>CFBundleTypeIconFiles</key> 
     <array> 
      <string>Icon.png</string> 
      <string>[email protected]</string> 
     </array> 
     <key>CFBundleTypeName</key> 
     <string>My Apps Files</string> 
     <key>CFBundleTypeRole</key> 
     <string>Editor</string> 
     <key>LSHandlerRank</key> 
     <string>Owner</string> 
     <key>LSItemContentTypes</key> 
     <array> 
      <string>public.composite-content</string> 
      <string>public.data</string> 
      <string>public.content</string> 
     </array> 
    </dict> 
</array> 
<key>UTExportedTypeDeclarations</key> 
<array> 
    <dict> 
     <key>UTTypeIdentifier</key> 
     <string>com.adobe.pdf</string> 
     <key>UTTypeDescription</key> 
     <string>PDF Document</string> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.data</string> 
      <string>public.composite-content</string> 
     </array> 
     <key>UTTypeTagSpecification</key> 
     <dict> 
      <key>public.filename-extension</key> 
      <array> 
       <string>pdf</string> 
      </array> 
      <key>public.mime-type</key> 
      <string>application/pdf</string> 
     </dict> 
    </dict> 
    <dict> 
     <key>UTTypeIdentifier</key> 
     <string>com.microsoft.word.doc</string> 
     <key>UTTypeDescription</key> 
     <string>Word Document</string> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.data</string> 
     </array> 
     <key>UTTypeTagSpecification</key> 
     <dict> 
      <key>public.filename-extension</key> 
      <array> 
       <string>doc</string> 
      </array> 
      <key>public.mime-type</key> 
      <string>application/msword</string> 
     </dict> 
    </dict> 
    <dict> 
     <key>UTTypeIdentifier</key> 
     <string>com.microsoft.excel.xls</string> 
     <key>UTTypeDescription</key> 
     <string>Excel Document</string> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.data</string> 
     </array> 
     <key>UTTypeTagSpecification</key> 
     <dict> 
      <key>public.filename-extension</key> 
      <array> 
       <string>xls</string> 
      </array> 
      <key>public.mime-type</key> 
      <string>application/vnd.ms-excel</string> 
     </dict> 
    </dict> 
</array> 

希望它可以幫助別人:)

祝好,

+0

您應該使用'UTImportedTypeDeclarations',因爲您不是這些類型的所有者。請參考Microsoft Word的Info.plist內容。 – adib 2015-12-27 15:57:17

回答

0

這是Doc文件formate的代碼,但它可能不適用於圖像。

<dict> 
<key>CFBundleTypeName</key> 
<string>Microsoft Word</string> 
<key>LSHandlerRank</key> 
<string>Alternate</string> 
<key>LSItemContentTypes</key> 
<array> 
<string>com.microsoft.word.doc</string> 
      <string>com.microsoft.word.wordml</string> 
      <string>org.openxmlformats.wordprocessingml.document</string> 
     </array> 
    </dict> 
相關問題