IOS 7 UIActivityViewController Email Attachments

I looked through a bunch of posts here, numerous online tutorials / code examples, and I'm at a standstill. In my application, I have no problem displaying the UIActivityController originally provided by iOS7 with the sharing settings appropriate for my application (AirDrop and mail).

The specific problem that I encountered is that my saved document is attached to an email when the user selects the option to exchange by mail. The body of the message is text-tuned, but the attachment is MIA. Relevant Code:

// Create an XML file that will be used for the currently displayed record ... NSURL * url = [self createShareFile];

UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[@"Data shared from my app.", url] applicationActivities:nil];

// Filter out the sharing methods we're not interested in....
controller.excludedActivityTypes = @[UIActivityTypePostToTwitter, UIActivityTypePostToFacebook,
                                UIActivityTypePostToWeibo,
                                UIActivityTypeMessage,
                                UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
                                UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll,
                                UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr,
                                UIActivityTypePostToVimeo, UIActivityTypePostToTencentWeibo];

// Now display the sharing view controller.
[self presentViewController:controller animated:YES completion:nil];

? , NSURL .

!

+4
1

.....

, , 100% . , NSURL, createShareFile:

( ):

return [NSURL URLWithString:[docFile stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

:

return [NSURL fileURLWithPath:docFile];

, .

+6

Source: https://habr.com/ru/post/1527611/


All Articles