Show up in the "Open in..." menu on iOS
来源:互联网 发布:淘宝客服结束语话术 编辑:程序博客网 时间:2024/04/30 19:22
How do I get my application to show up in the "Open in..." menu on iOS for a specific document type?
Q: How do I get my application to show up in the “Open in...” menu on iOS for a specific document type?
A: You need to register the document types that your application can open with iOS. To do this you need to add a document type to your app’s Info.plist for each document type that your app can open. Additionally if any of the document types are not known by iOS, you will need to provide an Uniform Type Identifier (UTI) for that document type.
Adding A Document Type
To add the document type do the following:
In your Xcode project, select the target you want to add the document type to.
Select the Info tab.
Click on the disclosure button for Document Types to open the document types.
Click the “+” button.
In the newly created document type :
Type the name of the document type.
In the “Types” section fill in the UTI for the new type.
Provide an icon for the document.
Click the disclosure triangle to open Additional document type properties.
Click in the table to add a new key and value.
For the key value type: CFBundleTypeRole.
For the value type: Editor.
Click the + button to add another key/value pair.
For the key value type: LSHandlerRank.
For the value type: Owner.
Adding A Custom UTI
If the document type you are adding is a custom document type, or a document type that iOS does not already know about, you will need to define the UTI for the document type. To add a new UTI do the following:
In your Xcode project select the target you want to add the new UTI to.
Select the Info tab.
Click on the disclosure button for Exported UTIs.
Click the “+” button.
Select “Add Exported UTI”.
In the Description field, fill in a description of the UTI.
In the Identifier field, fill in the identifier for the UTI.
In the Conforms To field fill in the list of UTIs that this new UTI conforms to.
Toggle the “Additional imported UTI properties” disclosure triangle to open up a table where you can add some additional information.
Click in the empty table and a list of items that can be added to the table will be displayed.
Type in “UTTypeTagSpecification”.
Set the type to Dictionary.
Click the disclosure triangle to open it, and click the + button in the table row to add an entry.
For the “New item” change the name to “public.filename-extension”.
For the type of the item change it to “Array”.
Toggle open the item you just added and click the + button in the table row.
For item 0 change the “value” to the file extension of your document. For example, txt, pdf, docx, etc.
Example
Here is a concrete example of a custom document type and exported UTI. Let’s say you were adding a new document type of cat information. If the document had the file extension 'catinfo' then when you were finished with the steps shown above, your information would look like this:
Example settings for a cat info document type.How To Test Your Custom Document Type
The easiest way to test your custom document type is to email your custom file to your iOS device. Navigate to the email and ensure that the attachment is there. Tap and hold the document attachment icon. This should open a popover on the iPad, or an action sheet on the iPhone, that shows all of the apps that open your document type. Your app should show up in the list. Tap your app icon and your app should launch and receive the document from the email.
Troubleshooting Tips
If your property list is not set up correctly then attempting to open your custom document from mail may not work. Symptoms are that your custom app shows up in the list of apps for your custom document type but the attachment is never handed off to your app. Compare your custom document type to the one shown in Figure 1 of this Q&A. Carefully comparing your document type field by field to the example frequently reveals errors.
Here are a few things you should check when things are not working as expected:
The public.filename-extension key is spelled correctly.
The public.filename-extension key/value is defined as an array not a string.
Each item in the public.filename-extension array is a string that does not start with a dot. For example, txt not .txt.
The type in the document type and the identifier in the exported (or imported) UTI are exactly the same. Copying and pasting this value is the easiest way to ensure that the values are identical.
转自 https://developer.apple.com/library/ios/qa/qa1587/_index.html#//apple_ref/doc/uid/DTS40012659
- Show up in the "Open in..." menu on iOS
- Clear the “Open With” menu in Mac OS X
- How to get files to show up in the Process Monitor/Report Repository
- Q:Is there any way to define what the "Open Resource" dialog in Eclipse should show?
- in/on the morning
- Module won't show up in “Edit Configuration”
- Show all the PC in DC
- Executing the Menu Commands in Excel
- How to show/hide a control in the Column's DataItemTemplate based on the value of another control
- Set up the VNC Server in Fedora
- 《在云端-up in the air》
- oracle You can disable statistics in the preference menu,or obtanin select priviliges on the v$sessi
- Plug-in, Switch On, Fall Over: Adventures with the Open Tools API
- Show hide file in finder on Mac OS X
- The open source project in China
- 右键添加open in the terminal
- My Open Mic in the openstack blog
- bzoj4099【Usaco2015 Open】Trapped in the Haybales
- PHP优化之高效率写法
- 字符串字串查找find, index, rfind, rindex
- Oracle数据操纵语言(DML)-更新数据
- 砝码问题
- 架构漫谈(八):从架构的角度看如何写好代码
- Show up in the "Open in..." menu on iOS
- Java日期格式化
- 一个tomcat配置两个端口,跑两个web项目
- 华东理工某ACMer总结
- 机房收费系统总结(一)
- Eclipse无法打开c++文件,报Editor could not be initialized.的错误
- springmvc批量文件打包成zip下载功能
- Computer Vision Resources
- JAVA_Kafka_producer_consumer