Reputation: 797
I Would like to know if i could use UIActivityViewController
so i can share a PDF file by email, or message, or other means possible.
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:linkToProspect]];
This is my PDF data that i would like to share.
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:*NSARRAY* applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
And this is the way i would like to do it.
Is there such a way ? Or should i create something custom ?
Upvotes: 0
Views: 3142
Reputation: 388
// pathToPDF should be a full path to your PDF file
NSString *pathToPDF = [[NSBundle mainBundle] pathForResource:@"ReadMe" ofType:@"pdf"];
NSURL *urlToPDF = [NSURL fileURLWithPath:pathToPDF];
NSMutableArray *itemsToShare = [[NSMutableArray alloc] init];
[itemsToShare addObject:urlToPDF];
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
Upvotes: 4