0
我收到內存警告3次,然後應用程序崩潰。收到內存警告目標c
我有一個滑塊,需要將模糊值更改爲UIImageView圖像。 我嘗試使用dispatch_async並使用imageView.image = nil清理圖像內存;但問題沒有解決。
從uislider此代碼調用:
dispatch_async(dispatch_get_main_queue(), ^(void)
{
imageView.image =nil;
imageView.image = [self blurImage:originalImage withValue:value];
});
-(UIImage *)blurImage:(UIImage *)theImage withValue:(nullable id)value
{
CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[gaussianBlurFilter setDefaults];
CIImage *inputImage = [CIImage imageWithCGImage:[theImage CGImage]];
[gaussianBlurFilter setValue:inputImage forKey:kCIInputImageKey];
[gaussianBlurFilter setValue:value forKey:kCIInputRadiusKey];
CIImage *outputImage = [gaussianBlurFilter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[inputImage extent]];
UIImage *image = [UIImage imageWithCGImage:cgimg];
return image;
}
謝謝它的作品( - : –