Prevent Preview of Custom UTI File Types on iPad
I have an iPad application with a custom file type declared via UTI and CFBundleDocumentTypes. Is there a way I can prevent applications like Mail and Dropbox from showing the file Preview while still allowing the "Open In..." option to launch my app? I have set UITypeConformsTo and UTTypeTagSpecification to custom values in the applicati开发者_运维百科on Info-plist, but the other apps are still previewing files with the custom extension created by my app. I thought the ability to preview was dependent on the value in the UTTypeTagSpecification (i.e. mime-type), but apparently not. Thanks.
The only solution I have found is to compress the file (e.g. ZIP). This will prevent iPad apps from displaying the contents. You do still need to be careful when declaring your custom doc types. Otherwise the app may still try to preview even though it's compressed, and end up displaying gibberish.
Each Quick Look generator's Info.plist defines the UTI types it can handle.
For Example: /System/Library/QuickLook/Text.qlgenerator/Contents/Info.plist is the path to the Info.plist for the default "Text" generator on my system.
The other two folders for generators are /Library/QuickLook and ~/Library/QuickLook.
You should see some lines like this at near the top:
<key>CFBundleTypeRole</key>
<string>QLGenerator</string>
<key>LSItemContentTypes</key>
<array>
<string>public.plain-text</string>
<string>public.rtf</string>
<string>com.apple.rtfd</string>
<string>org.oasis-open.opendocument.text</string>
<string>com.apple.property-list</string>
<string>public.xml</string>
</array>
Various Applications' Info.plist files define which file extensions belong to which UTI type. The operating system will use the file extension to get the UTI.
Your custom UTI/File Extension may be conflicting with an existing definition. That sounds like a likely cause for the problems you described.
I recommend looking through the defaults (and the exported UTI types for programs you have installed) and making sure your custom UTI (file extension as well!) really is 100% unique.
Don't have it inherit anything or some generator may decide it wants to try opening it.
精彩评论