I registered my own custom CFBundleDocumentTypes filetype as described in this link: How do I register a custom filetype in iOS
Everything is working fine except when I send a mail via MFMailComposeViewController there is still this plain default attachment icon instead of my own. When I receive the mail my own icon is displayed. Is it possible to change the default MFMailComposeViewController-attachment icon when sending the mail?
Thanks for your help, Martin
Attach a photo, video, or document to an emailabove the keyboard, then locate the document in Files. In Files, tap Browse or Recent at the bottom of the screen, then tap a file, location, or folder to open it. above the keyboard, then choose a photo or video.
Tap the attachment, then tap the gray arrow icon . Tap the Markup button to add your markup. Tap the plus button to add a signature, text, and more. Tap Done, then send your email.
When you add the attachment are you specifying the mime type correctly for your custom filetype? Perhaps you need to explicitly convert your UTI to a MIME type and then specify that when using the MFMailComposeViewController method:
- (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
Converting UTI to MIME type
NSString *filePath = ... // file path for your file of a custom type.
CFStringRef fileExtension = (__bridge CFStringRef)[filePath pathExtension];
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
CFRelease(UTI);
NSString *MIMETypeString = (__bridge_transfer NSString *)MIMEType;
Make sure to add and import the following frameworks:
#import <MobileCoreServices/MobileCoreServices.h>
#import <CoreServices/CoreServices.h>
Code snippet source: Damien DeVille
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With