在iOS設備上,郵件應用程序爲附件提供「打開在...」選項。列出的應用程序已在操作系統中註冊了CFBundleDocumentTypes。我想知道的是我的應用程序可能允許用戶在其他應用程序中打開由我的應用程序生成的文件。 Mail是唯一提供此功能的應用程序嗎?在iOS應用程序中添加「打開在...」選項
回答
看看Document Interaction Programming Topics for iOS: Registering the File Types Your App Supports。
只要你在你的Info.plist提供您的文檔類型,識別文檔類型的其他應用程序將列出在他們的「打開」選擇你的應用程序。當然,這假定你的應用程序創建了其他應用程序可以打開的文檔。
This是一個很棒的教程,幫助了我。
我已經添加了我的應用程序*.xdxf
文件的支持。總之,你必須做兩件事。首先 - 這樣的條目添加到您的應用程序的Plist
文件:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>XDXF Document</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.alwawee.xdxf</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>XDXF - XML Dictionary eXchange Format</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.alwawee.xdxf</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>xdxf</string>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
</array>
在這裏,你應該添加UTExportedTypeDeclarations
只有當你的文件類型是獨一無二的。或換句話說不是here。
二 - 在AppDelegate
處理委託方法:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if (url != nil && [url isFileURL]) {
// xdxf file type handling
if ([[url pathExtension] isEqualToString:@"xdxf"]) {
NSLog(@"URL:%@", [url absoluteString]);
}
}
return YES;
}
教程鏈接已損壞。 – 2015-06-28 12:45:53
爲了在所有文件「在打開的......」列表中可見,你需要添加到您的plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Open All Files</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>public.content</string>
<string>public.data</string>
</array>
</dict>
</array>
一旦您的應用程序顯示爲「在......中打開」,則需要加載該文件。大多數網站顯示來實現這個功能:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool
{
println("Open URL "+url.path!)
}
但這種功能運行良好的IOS在IOS 8.7崩潰我必須實現以下的功能,而不是得到它的工作。
func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool
{
println("Open URL "+url.path!)
}
添加我的應用程序在「打開方式」列表成功如下,
添加一個新的文件類型過濾器,它的名字是你想要的東西和類型在https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1
定義希望你也能成功!
不過,我要實現的功能是「分享」像Facebook或鬆弛呢,我不能讓它還是......誰能給我一個大大的手:(
- 1. 在iOS應用程序中打開URL
- 2. 我可以添加「打開」選項照片應用程序?
- 3. 在ios應用程序開發中添加日曆視圖
- 4. Chrome瀏覽器:在用戶打開選項後添加選項
- 5. 如何在ios應用程序中打開應用程序商店?
- 6. 如何在iOS應用程序中使用「打開...」功能?
- 7. 在方案選項中爲應用程序語言添加更多選項
- 8. 通過EMail打開IOS應用程序
- 9. 對於iOS應用程序打開
- 10. 從URL打開應用程序 - ios 10
- 11. 如何通過Facebook應用程序打開頁面在iOS中?
- 12. 強制iOS應用程序在safari中打開外部鏈接
- 13. 如何在設置中打開您的應用程序iOS 11
- 14. 如何在iOS應用程序中打開VRML(*。wrl)文件
- 15. 在iOS應用程序中打開電子郵件
- 16. 如何在Android/iOS應用程序中打開Trello網址
- 17. iOS如何在Mail應用程序中打開PDF?
- 18. 如何在iOS應用程序中打開iba(iBooks Author)書籍?
- 19. 在IOS應用程序中打開一個PDF
- 20. 打開.mobileconfig文件保存在Safari中的應用程序ios
- 21. 如何添加應用程序,以「打開方式」菜單中的iOS
- 22. 從我的iOS 5應用程序打開Twitter應用程序
- 23. 在firefox中打開oracle應用程序
- 24. 在Iframe中打開Express應用程序
- 25. 退出選項添加在Android應用程序
- 26. 「添加到收藏夾」 選項,在音板的應用程序
- 27. 在我的Android應用程序中打開vimeo應用程序?
- 28. 在我的應用程序中打開外部應用程序
- 29. 在PowerShell中選擇的應用程序中打開文件
- 30. 打開iOS應用程序時,打開某個模式的URL
我敢肯定的答案在這裏:http://stackoverflow.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application。 – 2011-12-13 16:55:26
提供相關信息的更新文章現在可以在[文檔交互編程主題(http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Articles/PreviewingandOpeningItems.html#//apple_ref/doc/uid/TP40010410-SW1「文檔交互編程主題「)。 – robotpukeko 2011-03-09 06:45:26