Ios 如何在设备中查看加载的文件
我正在从服务器下载一个pdf文件,我可以在模拟器中看到该文件,但在我的设备中找不到。我正在将文件保存到文档文件中。下面是我的代码,我相信我的代码是完美的Ios 如何在设备中查看加载的文件,ios,objective-c,pdf,download,Ios,Objective C,Pdf,Download,我正在从服务器下载一个pdf文件,我可以在模拟器中看到该文件,但在我的设备中找不到。我正在将文件保存到文档文件中。下面是我的代码,我相信我的代码是完美的 -(void)downloadPdfBtnPressed:(id)sender { NSString *dowloadURL = [DownloadUrlArray objectAtIndex:[sender tag ]]; NSString *filename =[dowloadURL lastPathComponent
-(void)downloadPdfBtnPressed:(id)sender
{
NSString *dowloadURL = [DownloadUrlArray objectAtIndex:[sender tag ]];
NSString *filename =[dowloadURL lastPathComponent];
NSString *stringPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0]stringByAppendingPathComponent:@"/PDFDownload"];
if (![[NSFileManager defaultManager] fileExistsAtPath:stringPath])
[[NSFileManager defaultManager] createDirectoryAtPath:stringPath withIntermediateDirectories:NO attributes:nil error:nil];
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:dowloadURL]];
if(pdfData)
{
stringPath = [stringPath stringByAppendingPathComponent:filename];
[pdfData writeToFile:stringPath atomically:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"PDF"
message:@"PDF file is downloaded"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
欢迎来到堆栈溢出!你能解释一下你的问题是什么吗?你的代码做什么;图像大小有什么问题?您可以使用该按钮添加更多说明。这样,您就更有可能获得一些帮助。最好将库链接到iCarousel,因为这不是IOS的固有功能:检查
writeToFile
中的返回值,并使用返回NSError
对象的版本,失败时,记录错误描述。@特洛伊木马返回值显示sdata,我的问题是,我无法在我的设备中查看下载的文件。您是否已打开文件共享以便在iTunes中查看该文件?