Show icons for custom UTIs in UIDocumentPickerViewController

IOS App I am working on exporting UTI. The relevant parts Info.plist

are as follows:

<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.xml</string>
            <string>public.data</string>
        </array>
        <key>UTTypeDescription</key>
        <string>GPX Document</string>
        <key>UTTypeIdentifier</key>
        <string>de.company.app.gpx</string>
        <key>UTTypeSize320IconFile</key>
        <string>Doc320.png</string>
        <key>UTTypeSize64IconFile</key>
        <string>Doc64.png</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>gpx</string>
            </array>
        </dict>
    </dict>
</array>

      

I want the application to process GPX files through the "Open in ..." dialogs, so there is also a document type definition (which refers to the UTI) in the same PLIST:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Icon29.png</string>
            <string>Icon58.png</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>de.company.app.gpx</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>de.company.app.gpx</string>
        </array>
    </dict>
</array>

      

When opening GPX files in Safari, it displays the icon indicated in CFBundleTypeIconFiles

, i.e. Icon58.png

, on the retina device. The app also lets you import through the UIDocumentPickerViewController class introduced in iOS 8, and while the UTI definition is great for filtering matching files in iCloud Drive, it doesn't display any of my assignments:

I guarantee that all image files are bound ( Icon29.png

, Icon58.png

, Doc64.png

, Doc320.png

) is actually located in the root directory of the application. The numbers in their names indicate their height in pixels. The files Doc...

are squares, the other two follow this specification (iPhone only).

I have basically two questions:

1) How do I get the UIDocumentPickerViewController to display custom icons for our UTIs?

2) Are there other use cases that use UTTypeSize64IconFile

and UTTypeSize320IconFile

?

+3


source to share


2 answers


Unfortunately, the answer is that this is not possible unless your application has control over how these files are written to disk. In this case, you can subclass UIDocument

and record the thumbnails. Here is the original answer posted by an Apple engineer posted on the Apple developer forums (login required). It includes sample code to illustrate how this is done.



I have not yet found the answer to the second part of my question.

+3


source


I believe you are using the wrong size icons in the CFBundleTypeIconFiles key. The size you are using is the settings icon.

To test my theory, add a few more files of different sizes. Plus all the badges are square. The image you see in your question looks rectangular.

According to Icon and Image Design -> Application Icon :

Document icons

If your iOS app creates custom type documents, you want users to be able to immediately recognize these documents. You don't need to create a custom icon for this purpose as iOS uses your app's icon to create document icons for you.

And an excerpt from Application Icons :



App icon (required) (iPhone)

  • 60 x 60 pixels
  • 120 x 120 pixels (@ 2x)

This is the main icon for applications running on iPhone and iPod touch in iOS 7 and later.

Settings icon (all devices)

  • 29 x 29 pixels
  • 58 x 58 pixels (@ 2x)
+1


source







All Articles