如何在ipad中注册应用程序以打开我的应用程序中的pdf文件

utt*_*tam 18 objective-c ipad

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

这是我的info.plist文件

 <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>
Run Code Online (Sandbox Code Playgroud)

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

Ash*_*ark 50

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

例如:

<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>
Run Code Online (Sandbox Code Playgroud)

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

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

  • 这是iOS 4+的更新,应用程序可以在后台运行.application:didFinishLaunchingWithOptions:仅在您的应用程序尚未运行时调用.要确保在应用程序运行时获取传入文件,可以实现应用程序:handleOpenURL:(或者应用程序:openURL:sourceApplication:annotation:在iOS 4.2+中). (5认同)