当我使用 URL 将 PDF 保存到文件时,保存的 pdf 不会显示在 Itunes/我的 iPad 名称/Apps/MyApp 的文档窗口中。实际上,我什至在文件共享部分下看不到我的应用程序。像“dropbox”或“pages”这样的应用程序是如何做到这一点的?
使用的代码
//我想要的pdf的url
NSURL *pdfURL = [NSURL URLWithString:@"http://manuals.info.apple.com/en/iphone_user_guide.pdf"];
//获取我们的文档目录的路径
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//这应该是我们的文档目录
NSString *saveDirectory = [documentPath objectAtIndex:0];<br/>
NSString *saveDirectory2 = [[saveDirectory stringByAppendingPathComponent:@"myfile.pdf"] retain];
//将我的 PDF 转换为 NSData,也许我无法从 PDF 转换?
NSData *dataToWrite = [NSData dataWithContentsOfURL:pdfURL];
//将转换后的pdf写入内存中的路径
BOOL status = [dataToWrite writeToFile:saveDirectory2 atomically:YES];
最佳答案
您是否已按照此处的说明将 UIFileSharingEnabled 键添加到应用的 Info.plist 文件并将其值设置为 YES?:
没有它,iTunes 将看不到您应用的文档目录中的内容。
关于iphone - iOS开发: Saved file does not show up in itunes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4108410/