Ios 在iBook中打开名称中带有空格的PDF

Ios 在iBook中打开名称中带有空格的PDF,ios,ipad,Ios,Ipad,我已经在我的PDF查看器中实现了第n次讨论的“在iBook中打开”功能。当PDF文件不包含空格(example1.PDF,example2.PDF)时,它非常有效。当PDF的名称中有一些空格(例如1.PDF)时,单击“在iBook中打开”按钮不会执行任何操作 NSString *fileURL = [(Documents *)(self.detailItem) url]; NSArray *subStrings = [fileURL componentsSeparatedByString:@"/

我已经在我的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];

欢迎任何建议。谢谢:)

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

因为文件路径字符串是一个URL,所以在调用
fileURLWithPath:

之前,您可能需要先运行它,然后再调用
NSLog(@“%@,[subStrings lastObject])某处并告诉我们结果?用引号括起来,即使没有空格的文件也无法打开