我是靠谱客的博主 精明歌曲,最近开发中收集的这篇文章主要介绍邮件附件在应用中打开 How do I get my application to show up in the "Open in..." menu on iOS for a specific document type?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

【iOS】https://developer.apple.com/library/ios/#qa/qa1587/_index.html



Technical Q&A QA1587

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:

  1. In your Xcode project, select the target you want to add the document type to.

  2. Select the Info tab.

  3. Click on the disclosure button for Document Types to open the document types.

  4. Click the “+” button.

  5. 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.

  6. Click the disclosure triangle to open Additional document type properties.

  7. Click in the table to add a new key and value.

    • For the key value type: CFBundleTypeRole.

    • For the value type: Editor.

  8. Click the + button to add another key/value pair.

    • For the key value type: LSHandlerRank.

    • For the value type: Owner.

Back to Top

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:

  1. In your Xcode project select the target you want to add the new UTI to.

  2. Select the Info tab.

  3. Click on the disclosure button for Exported UTIs.

  4. Click the “+” button.

  5. 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.

  6. Toggle the “Additional imported UTI properties” disclosure triangle to open up a table where you can add some additional information.

  7. Click in the empty table and a list of items that can be added to the table will be displayed.

  8. Type in “UTTypeTagSpecification”.

  9. Set the type to Dictionary.

  10. Click the disclosure triangle to open it, and click the + button in the table row to add an entry.

  11. For the “New item” change the name to “public.filename-extension”.

  12. For the type of the item change it to “Array”.

  13. Toggle open the item you just added and click the + button in the table row.

  14. For item 0 change the “value” to the file extension of your document. For example, txt, pdf, docx, etc.

Back to Top

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 and the file had an extension of catinfo then when you were finished with the steps above your information would look like this:

Figure 1  Example settings for a cat info document type.

最后

以上就是精明歌曲为你收集整理的邮件附件在应用中打开 How do I get my application to show up in the "Open in..." menu on iOS for a specific document type?的全部内容,希望文章能够帮你解决邮件附件在应用中打开 How do I get my application to show up in the "Open in..." menu on iOS for a specific document type?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(68)

评论列表共有 0 条评论

立即
投稿
返回
顶部