0

我已经在我的 PDF 查看器中实现了已经讨论过的第 n 次在 iBook 中打开的功能。当 PDF 文件不包含空格(example1.pdf、example2.pdf)时效果很好。当 PDF 的名称中有一些空格(例如 1.pdf)时,单击在 iBook 中打开按钮不会执行任何操作。

NSString *fileURL = [(Documents *)(self.detailItem) url];
NSArray *subStrings = [fileURL componentsSeparatedByString:@"/"];
NSString *filePath = [[self documentsDirectory] stringByAppendingPathComponent:[subStrings lastObject]];
docIntController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
docIntController.delegate = self;
docIntController.UTI = @"com.adobe.pdf";

[docIntController presentOptionsMenuFromBarButtonItem:sender animated:YES];

欢迎任何建议。谢谢 :)

4

2 回答 2

2

由于 filePath 字符串旨在成为 URL,因此您可能需要NSString -stringByAddingPercentEscapesUsingEncoding:在调用之前运行它fileURLWithPath:

于 2012-05-20T21:11:44.843 回答
0

尝试用引号将您发送到 iBooks 的完整路径括起来。例如,使用“example 1.pdf”而不是 example1.pdf。

于 2012-05-20T21:05:37.430 回答