【发布时间】:2013-03-02 08:16:25
【问题描述】:
我是新来的,请帮助我。我想从给定的 url 下载 .epub 或 .pdf (例如: www.example.com./file.pdf )并将其以特定名称(整数)存储到我的 iOS 设备中,如果我想打开那本书,我可以能够检查它是否是我想要的书。
【问题讨论】:
-
我得到了答案:在视图 didload () 中使用以下 2 个代码
-
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"pewinternet.org/~/media/Files/Reports/2008/…; //将数据本地存储为PDF文件 NSString *resourceDocPath = [[NSString alloc] initWithString:[ [[[NSBundle mainBundle] resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
-
NSString *filePath = [resourceDocPath stringByAppendingPathComponent:@"11011.pdf"]; [pdfData writeToFile:filePath atomically:YES]; NSLog(@"%@",filePath); //现在为保存在您的文档文件夹中的文件创建请求 NSURL *url = [NSURL fileURLWithPath:filePath]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webview setUserInteractionEnabled:YES]; [webview setDelegate:self]; [webview loadRequest:requestObj];
-
回答您自己的问题.. 标记答案很重要,以便对可能参考此问题的用户有所帮助
-
sharanya,我只能在 8 小时后将其标记为答案,它的堆栈溢出规则可能是因为我是这里的新用户
标签: xcode pdf ios6 epub downloadfile