Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActivityViewController - preserve file name of attached files from read from URL

Is there an equivalent code to this (code below) for iOS6 UIActivityViewController? The question is, can I share data via url and preserve the file name? As of now the only way I can figure out how to do it is to convert the PDF to NSData and add the data as an activityItem. Works fine, but I lose the name of the attached pdf.

[composer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"myPDF.pdf"];
like image 797
Mr Ordinary Avatar asked Sep 12 '25 20:09

Mr Ordinary


1 Answers

yes I think it is possible, try this

NSString *str = [[NSBundle mainBundle] pathForResource:@"AppDistributionGuide" ofType:@"pdf"]; 
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Test", [NSURL fileURLWithPath:str]] applicationActivities:nil];
like image 95
Ned Avatar answered Sep 15 '25 11:09

Ned