Custom Document Types
Using an Image as a Custom Document Type Icon in Xamarin.iOS.
- PDF for offline use
- Sample Code:
- Related Articles:
- Related SDKs:
Let us know how you feel about this
last updated: 2016-12
This article covers including and managing an image asset in a Xamarin.iOS app to be used as a Custom Document Type Icon.
If a Xamarin.iOS app supports loading a particular document type, the developer can provide icons that the system will use when it encounters that document type, such as when a user holds down an attachment in the Mail Application as shown here:
The developer can add document type information for a file format the app is capable of opening by including dictionary entries for the
CFBundleTypeName string and
LSItemContentTypes array in the app's
Info.plist. The icons for the document type go in the
CFBundleTypeIconFiles array. If a document icon isn't provided, iOS will derive one from the app icon.
Icons can be supplied for several sizes, optimized for the various device resolutions.
To assign these values in Xamarin Studio, use the Document Types section under the Advanced tab on the
editor to add the document type and assign image icons to it. For
example, here is a screenshot showing registration for PDF support:
There is no advanced plist editor in Visual Studio at this time, so document icons have to be edited manually. Double click on the
Info.plist file to open it, and add the following code under
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array> <string>Resources/doc_icon.png</string> <string>Resourcesemail@example.com</string> </array> <key>CFBundleTypeName</key> <string>PDF</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>com.adobe.pdf</string> </array> </dict> </array>