Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
Image 如何处理大尺寸的多个图像?_Image_Ios9_Phasset_Photosframework - Fatal编程技术网

Image 如何处理大尺寸的多个图像?

Image 如何处理大尺寸的多个图像?,image,ios9,phasset,photosframework,Image,Ios9,Phasset,Photosframework,我有从照片库中选择的图像列表。 阵列列表包含从照片中选择的相位集 <PHAsset: 0x131334350> 768AD8BA-FE7A-4EE9-B2CF-4DD4AEBE2AE9/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2016-03-11 06:50:09 +0000, location=1, hidden=0, favorite=0 ", "<PHAsset: 0x131334260

我有从照片库中选择的图像列表。 阵列列表包含从照片中选择的相位集

 <PHAsset: 0x131334350> 768AD8BA-FE7A-4EE9-B2CF-4DD4AEBE2AE9/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2016-03-11 06:50:09 +0000, location=1, hidden=0, favorite=0 ",
"<PHAsset: 0x131334260> CA962E42-A367-4E8D-85C8-934F8C76FE78/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2016-03-11 06:50:08 +0000, location=1, hidden=0, favorite=0 "
但问题是,当我选择了多张大尺寸(超过25张)的图片时,应用程序崩溃了。因为当我使用PHImageManager将PHAsset转换为原始图像时,它使用了设备的高内存。
请帮我解决这个问题。如果有任何其他解决方案来处理选定的相集以将图像存储在应用程序文档目录中,请提供给我。

使用数据处理所有图像,而不是转换为原始图像

     [manager requestImageDataForAsset:asset
                              options:self.requestOptions
                        resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info)
     {
        // UIImage *image = [UIImage imageWithData:imageData];
         [Albumimages addObject:imageData];

     }];
然后在文档目录路径中写入图像数据

 PHImageRequestOptions *option = [PHImageRequestOptions new];
 option.synchronous = NO;

let screenSize: CGSize = UIScreen.mainScreen().bounds.size
let targetSize = CGSizeMake(screenSize.width, screenSize.height)

 [manager requestImageForAsset:asset
                    targetSize:target 
                   contentMode:PHImageContentModeAspectFill 
  options:option resultHandler:^(UIImage *result, NSDictionary *info) 
  {
        //this block will be called synchronously
   }];

如果在使用更多图像时设置最大图像大小,它们可能会崩溃,但如果设置目标大小,则会对其进行处理。

当原始大小较大的图像从PHAsset内存中获取时,设置内存用于跳转到高位,则处理无效。
 PHImageRequestOptions *option = [PHImageRequestOptions new];
 option.synchronous = NO;

let screenSize: CGSize = UIScreen.mainScreen().bounds.size
let targetSize = CGSizeMake(screenSize.width, screenSize.height)

 [manager requestImageForAsset:asset
                    targetSize:target 
                   contentMode:PHImageContentModeAspectFill 
  options:option resultHandler:^(UIImage *result, NSDictionary *info) 
  {
        //this block will be called synchronously
   }];