iphone - iOS开发: Saved file does not show up in itunes

标签 iphone file ios save

当我使用 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?:

http://developer.apple.com/library/ios/#documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html%23//apple_ref/doc/uid/TP40009252-SW20

没有它,iTunes 将看不到您应用的文档目录中的内容。

关于iphone - iOS开发: Saved file does not show up in itunes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4108410/

相关文章:

linux - 在 ramdisk 上缓存 - 查找要删除的最旧文件

ios - UIbutton 的圆角扰乱了其宽度

ios - 有什么方法可以在不重新加载/重新加载行的情况下刷新单元格的高度?

ios - “NSAttributedString initWithData: options: documentAttribute: error:” 在 iOS 10 中给出 <img src/> 标签时不工作

iOS - 如何在应用程序中使 iPhone 静音/响铃

iphone - 在 Objective C 中使用 block 编程进行内存管理

iphone - 在 iPhone 模拟器中模拟飞行模式

iphone - XCode 4 中的调试器

C# 文件名显示有空格问题

python : Printing contents of a file to the terminal