如何將iPhone應用程式與_every_檔案型別相關聯?
有iPhone應用程式“另一個郵件客戶端”,應該能夠開啟任何檔案作為附件傳送.所以,我想將此應用程式與任何副檔名的檔案相關聯.
遵循文件,我們應該宣告對根UTI型public.data的檔案的支援 – 任何檔案應屬於此型別.它的作品,但根本沒有.在這種情況下,我們的應用程式將無法開啟任何檔案,只能開啟已經在系統中註冊的檔案.例如,如果在任何應用程式(例如,保管箱)中,我們將嘗試使用UIDocumentInteractionController“未知副檔名(file.unknowntype)”開啟…檔案,那麼答案將為負,儘管我們已經註冊我們的應用程式,它支援根UTI型public.data.但是,如果您安裝另一個應用程式,它支援具有副檔名(* .unknowntype)的檔案,那麼我們的應用程式也將能夠開啟這些檔案,並將出現在“開啟…”應用程式列表中.
UPD:@Gabriel這是CFBundleDocumentTypes我的info.plist檔案的一部分:
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>MyMail</string> <key>LSItemContentTypes</key> <array> <string>public.data</string> </array> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Default</string> <key>CFBundleTypeIconFiles</key> <array> <string>Icon29.png</string> ... <string>Icon114.png</string> </array> </dict> </array>
我已經通過以下設定製作了一個應用程式
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>name</string> <key>LSItemContentTypes</key> <array> <string>public.data</string> </array> </dict> </array>
當我嘗試從Safari開啟.pdf時,此應用程式顯示在“開啟..”列表中.你可以製作一個示例應用程式並嘗試嗎?
UPD:
似乎聲稱’public.data'(也試過public.item,public.content)是指檔案,它屬於設定“所有系統UTI都知道”,而不是任何檔案.所以,您將能夠處理ofollow,noindex" target="_blank">99% of files ,哪些使用者希望通過電子郵件傳送,但不是全部.另外一種方法是出口您認為重要的UTI,但預設情況下不在系統UTI中.
http://stackoverflow.com/questions/9362630/how-to-associate-iphone-application-with-every-file-type