Search code examples
iphoneipadmime-typesuticfbundledocumenttypes

Cannot add icon to registered document type? Is this a bug?


I am trying to add icons to the document type I have defined using Xcode document type option on the project info.

enter image description here See the phrase add icons here? In theory you can drop icons to that area. I have tried png, ico, icns. Nothing.

I have tried to add the icons by clicking on the + there, nope. I click on the +, I choose the files and nothing happens.

The icon you see there I was able to drop to the place it is, that is another droppable place.

My problem is this:

  1. I have dropped a 320x320 png to the place you see the icon.
  2. I use the following code to obtain the icon at run time and display it.

    UIDocumentInteractionController* docController = [[UIDocumentInteractionController alloc] init];
    docController.name = [NSString stringWithFormat:@"x.%@", [[fileURL path] pathExtension]]; // it is x, but it can be anything
    NSArray *icons = (NSArray *)[docController icons];
    

The array I get has two icons, both with the same size that is 37x48 in size (???!!!)

two questions

  1. can you confirm if this is a bug and there is no way to add icons there?
  2. can you confirm if this code is what I have to use to get the icon?

Apple documentation is vague. I don't know if these icons have to have a special nomenclature. My big icon is something like bigIcon.png and the small one is smallIcon.png.


Solution

  • required icon sizes are

    • iPad 320x320, 64x64
    • iPhone 44x58, 22x29

    you have to modify .plist manually (i didn't find another way yet)

    <key>CFBundleDocumentTypes</key>
    <array>
    <dict>
    <key>CFBundleTypeIconFiles</key>
    <array>
    <string>icon320x320.png</string>
    <string>icon64x64.png</string>
    <string>icon44x58.png</string>
    <string>icon22x29.png</string>
    </array>
    <key>CFBundleTypeName</key>
    <string>mydocumenttype</string>
    <key>CFBundleTypeRole</key>
    <string>Viewer</string>
    <key>LSHandlerRank</key>
    <string>Owner</string>
    <key>LSItemContentTypes</key>
    <array>
    <string>xyz.mydocument.uti</string>
    </array>
    </dict>
    </array>