Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

objective c - how to register the app to open the pdf file in my app in ipad

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.

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>

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

For example:

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

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...