Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何从图像视图本地保存pdf_Iphone_Ipad - Fatal编程技术网

Iphone 如何从图像视图本地保存pdf

Iphone 如何从图像视图本地保存pdf,iphone,ipad,Iphone,Ipad,如何在本地保存pdf 我已将pdf文档加载到imageView中。现在我需要将数据保存到本地iPhone设备中 有人建议我如何从图像视图保存pdf文件吗 @全部 提前感谢您将pdf保存在文档目录中,请使用下面的代码 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [path

如何在本地保存pdf

我已将pdf文档加载到imageView中。现在我需要将数据保存到本地iPhone设备中

有人建议我如何从图像视图保存pdf文件吗

@全部


提前感谢您将pdf保存在文档目录中,请使用下面的代码

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"data.pdf"];

        NSData *thedata = [NSData dataWithContentsOfURL:[NSURL URLWithString:`ADD URL OF PDF DATA`]];

        [thedata writeToFile:localFilePath atomically:YES];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString *documentsDirectory = [paths objectAtIndex:0];
            NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"data.pdf"];
if ( [[NSFileManager defaultManager] fileExistsAtPath:localFilePath] ) {
            NSData *data = [NSData dataWithContentsOfFile:localFilePath];
        }
要检索pdf,请使用下面的代码

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"data.pdf"];

        NSData *thedata = [NSData dataWithContentsOfURL:[NSURL URLWithString:`ADD URL OF PDF DATA`]];

        [thedata writeToFile:localFilePath atomically:YES];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString *documentsDirectory = [paths objectAtIndex:0];
            NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"data.pdf"];
if ( [[NSFileManager defaultManager] fileExistsAtPath:localFilePath] ) {
            NSData *data = [NSData dataWithContentsOfFile:localFilePath];
        }