如何注册应用程序以在 ipad 中的我的应用程序中打开 pdf 文件 [英] how to register the app to open the pdf file in my app in ipad

查看:23
本文介绍了如何注册应用程序以在 ipad 中的我的应用程序中打开 pdf 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中从 pdf 页面打开 pdf 文件,但我没有在我的应用程序中打开 pdf 的任何选项.

i want to open the pdf file in my app from pdf page, but i am not getting any option of opening the pdf in my app.

这是我的 info.plist 文件

this my info.plist file

 <key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
    <key>CFBundleTypeName</key>
    <string>PDF</string>
    <key>CFBundleTypeRole</key>
            <string>Viewer</string>     
    <key>CFBundleTypeIconFiles</key>
    <string>Icon.png</string>
    <key>LSItemContentTypes</key>
    <string>com.neosofttech.pdf</string>
    <key>LSHandlerRank</key>
    <string>Owner</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
   <array>
   <dict>
    <key>UTTypeConformsTo</key>
        <array>

<string>public.pdf</string>       
         </array>
    <key>UTTypeDescription</key>
    <string>PDFReader File</string>
    <key>UTTypeIdentifier</key>
    <string>com.neosofttech.pdf</string>
    <key>UTTypeTagSpecification</key>
    <dict>
        <key>public.filename-extension</key>
        <string>pdf</string>

    </dict>
</dict>

请告诉我我错在哪里,如何在我的应用程序中打开 pdf 文件.

pls tell me where i am wrong in this, how can i open the pdf file in my app.

推荐答案

我假设您正在尝试根据此处的 plist 从邮件中打开附件.由于您不拥有 PDF 文件类型,因此无法将其声明为导出类型.您只需将其声明为支持的文档类型即可.

I'm assuming that you're trying to open an attachment from within Mail based on your plist here. Since you don't own the PDF file type you can't declare it as an exported type. You only need to declare it as a supported document type.

例如:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PDF</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
</array>

您可以找到系统提供的所有内容类型的列表 此处UTCoreTypes.h.

You can find a list of all of the system supplied content types here or in UTCoreTypes.h.

当有人打开 PDF 文件并选择您的应用程序时,该文件将被复制到应用程序沙箱中 Documents 文件夹的 Inbox 子目录中.然后,您的应用将被打开,并且在您的应用委托的 application:didFinishLaunchingWithOptions: 中,您的 launchOptions 字典将包含一个 UIApplicationLaunchOptionsURLKey 键,用于指定文件的 URL在您可以使用的沙箱中.

When someone does open a PDF file and chooses your application that file will be copied to an Inbox subdirectory of your Documents folder in your app sandbox. Your app will then be opened and within your app delegate's application:didFinishLaunchingWithOptions: your launchOptions dictionary will contain a UIApplicationLaunchOptionsURLKey key specifying the URL of the file within your sandbox that you can then work with.

这篇关于如何注册应用程序以在 ipad 中的我的应用程序中打开 pdf 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆