15

I have a problem registering image file types to my application. I tried adding the code below to my plist but nothing happens.

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>Scary Bug Document</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.image</string>
            </array>
        </dict>
    </array>

I noticed that I can register for other file types, such as text (changing the public.image to public.text) but it just won't work with images (the "Open In .." menu is not showing my app).

What could be causing this, and how could I fix it?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Alex Stanciu
  • 5,183
  • 2
  • 24
  • 31

7 Answers7

7

It is now possible to open images from the mail app in iOS 7, it's just somewhat convoluted:

Tap and hold the image. Tap on Quick Look so the image goes fullscreen. Tap the image to show the top toolbar. Tap the open in button at the top right. Scroll the list to the left to find your app.

Be sure to set up your bundle document types for the image types you are interested in.

Dimitri Bouniol
  • 735
  • 11
  • 15
  • Is this a new feature added to iOS7 ? Can you open images from camera roll or just from the mail application ? – Alex Stanciu Feb 25 '14 at 22:36
  • 1
    @Artanis Seems like it is new to iOS 7. This also seems to work in every app that exports images *except* the Photos and Camera apps… – Dimitri Bouniol Feb 26 '14 at 02:30
7

Dimitri Bouniol response that it works in iOS 7 via quick look is correct. The following additions to my in info.plist below are how I got it to work for my app. Still have not figured out how to get share in photos or camera roll to work.

  <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>myapp image</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>public.png</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.png</string>
                <string>public.jpeg</string>
            </array>
        </dict>
    </array>
    <key>UTImportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.image</string>
            </array>
            <key>UTTypeIdentifier</key>
            <string>public.png</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>com.apple.ostype</key>
                <string>PNG</string>
                <key>public.filename-extension</key>
                <array>
                    <string>png</string>
                </array>
                <key>public.mime-type</key>
                <string>image/png</string>
            </dict>
        </dict>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>public.jpeg</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.w3.org/Graphics/JPEG/</string>
            <key>UTTypeDescription</key>
            <string>JPEG image</string>
            <key>UTTypeIconFile</key>
            <string>public.jpeg.icns</string>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.image</string>
                <string>public.data</string>
            </array>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>com.apple.ostype</key>
                <string>JPEG</string>
                <key>public.filename-extension</key>
                <array>
                    <string>jpeg</string>
                    <string>jpg</string>
                </array>
                <key>public.mime-type</key>
                <string>image/jpeg</string>
            </dict>
        </dict>
    </array>
bret
  • 796
  • 9
  • 5
2

Try:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>Scary Bug Document</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.png</string>
                <string>public.jpg</string>
            </array>
        </dict>
    </array>

Also, see this other answer on StackOverflow

Community
  • 1
  • 1
Barlow Tucker
  • 6,229
  • 3
  • 36
  • 42
2

After doing a bit of research it seems that is not possible to register the app for images. Thanks for your answers.

Alex Stanciu
  • 5,183
  • 2
  • 24
  • 31
1

Per Apple's documentation, "to add the document type do the following:

  • Click on the disclosure button for Document Types to open the document types.
  • In the “Types” section fill in the UTI for the new type.
  • For the key value type: CFBundleTypeRole.
  • For the value type: Editor.
  • For the key value type: LSHandlerRank.
  • For the value type: Owner."

This works for me using public.image as the UTI.

1

public.image is an abstract type, try registering for public.png or public.jpeg etc

wattson12
  • 11,176
  • 2
  • 32
  • 34
  • i tried those too but still no luck ... and by the way it should work with public.image as it works for public.text but I am missing something – Alex Stanciu Feb 08 '12 at 18:29
0

OS will not allow you to open images in your app. I also tried myself a lot of permutation & combination, and confirmed from a few more posts in Apple Support.

rishabh
  • 1,155
  • 1
  • 10
  • 17