How to send a PDF file using UIActivityViewController

前端 未结 8 1075
野趣味
野趣味 2020-12-13 13:57

I\'m trying to send a PDF using a UIActivityViewController. So far everything works fine using a fairly basic approach but the one issue I have is that when I s

8条回答
  •  执念已碎
    2020-12-13 14:42

    The reply by Muruganandham K is simple and quite elegant. However, it doesn't work in iOS 9. In order to make it work, if you remove the @[@"Test" and just pass the pdfData, an attachment is made.

    NSData *pdfData = [NSData dataWithContentsOfFile:pdfFilePath];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:pdfData applicationActivities:nil];
    
    [self presentViewController:activityViewController animated:YES completion:nil];
    

提交回复
热议问题