2014-02-10 18 views
7

我希望我的應用出現在UIActivityViewController中以用於其他應用中的文本。例如,如下所示從Notes應用程序共享時。如何讓我的應用程序出現在UIActivityViewController中用於文本?

enter image description here

添加以下到Info.plist中沒有產生任何明顯的效果(在Notes中,Evernote的和Simplenote):

<key>CFBundleDocumentTypes</key> 
<array> 
    <dict> 
     <key>CFBundleTypeIconFiles</key> 
     <array> 
      <string>icon-text-57.png</string> 
      <string>icon-text-72.png</string> 
      <string>icon-text-114.png</string> 
     </array> 
     <key>CFBundleTypeName</key> 
     <string>Text</string> 
     <key>LSHandlerRank</key> 
     <string>Alternate</string> 
     <key>LSItemContentTypes</key> 
     <array> 
      <string>public.text</string> 
      <string>public.plain-text</string> 
      <string>public.utf8-plain-text</string> 
      <string>public.utf16-external-plain-​text</string> 
      <string>public.utf16-plain-text</string> 
      <string>public.rtf</string> 
     </array> 
    </dict> 
</array> 

這可能嗎?怎麼樣?

回答

8

簡短的回答:你不能。

目前,您不能將您的應用程序添加到其他UIActivityViewControllers,除非您創建自己的UTI並且應用程序(Notes,Evernote和Simplenote)將代碼添加到他們的應用程序中以顯示您的應用程序。

您可能指的是UIDocumentInteractionController,這是不同的,您可以添加您的應用程序,並且我相信您正確地做到了這一點。

你正在嘗試的東西都是UIActivityViewControllers所以無論你多努力嘗試,你的應用程序都不會出現在那裏。

快速註釋補充:區分的一個好方法是UIActivityViewControllersUIDocumentInteractionController是看看是否有「Dropbox」出現。根據我的經驗,Dropbox應用程序有一個「全能」UTI,可以接收任何文件,因此通常可以在幾乎所有的UIDocumentInteractionController中找到。當然,你需要安裝應用程序

+1

這是真的嗎?也許我誤解了你的答案,但我在第二行圖標中的一個簡單的「UIActivityViewController」中看到「保存到Dropbox」。我希望我的應用程序能夠與它一起出現,並且它使用'UIDocumentInteractionController',但不能與Dropbox一起放入'UIActivityViewController'中。 –

+1

@TimCamber好點。此信息已過時iOS 8,其中分享擴展已添加,並且是正確的方式。我會更新答案。 – Jack

1

plist是錯誤的,看到這樣的回答:Why is my iOS app not showing up in other apps' "Open in" dialog?但對我來說,它看起來像您尚未設置LSHandlerRankplist

另外:一定要按照蘋果自己的文檔:https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/RegisteringtheFileTypesYourAppSupports.html

+0

嗯。 「LSHandlerRank」就在那裏? – hpique

+0

對不起!我想我錯過了...... – virindh

+0

等等!你爲什麼要在之後完成你的陣列CFBundleTypeIconFiles? – virindh

相關問題