附加word或Excel文件时出现UIActivityViewController问题

时间:2016-02-29 10:55:24

标签: ios objective-c

我在iOS应用中使用UIActivityviewcontroller。它作为附件正常工作pdf文件但是当我附加word或excel文件时不起作用。我使用下面的代码

    NSData *pdfData = [NSData dataWithContentsOfURL:<Server fileUrl>];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"FileName", pdfData] applicationActivities:nil];
     [self presentViewController:activityViewController animated:YES completion:nil];

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

使用 UIDocumentInteractionController

UIDocumentInteractionController *pdfData = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileNameStr]];
[pdfData presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];

点击此处了解更多详情。 UIDocumentInteractionController_class