我正在使用此功能裁剪图像,当我使用它时,它不释放内存,我试图不使用它,内存工作正常。我不能似乎与it.Please帮助内存问题我创建了IOS 7
- (void) processImage:(UIImage *)image {
haveImage = YES;
UIGraphicsBeginImageContext(image.size);
[image drawInRect: CGRectMake(0, 0, image.size.width, image.size.height)];
__weak UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect cropRect = CGRectMake(0, 0, image.size.width, image.size.height - ((image.size.height - image.size.width)/2));
CGImageRef imageRef = CGImageCreateWithImageInRect([smallImage CGImage], cropRect);
__weak UIImage *corteSuperior =[UIImage imageWithCGImage:imageRef];
cropRect = CGRectMake(0, ((image.size.height - image.size.width)/2), corteSuperior.size.width, corteSuperior.size.height - ((image.size.height - image.size.width)/2));
imageRef = CGImageCreateWithImageInRect([corteSuperior CGImage], cropRect);
self.imagenCamara.image = [UIImage imageWithCGImage:imageRef];
smallImage = nil;
imageRef = nil;
corteSuperior = nil;
UIGraphicsEndImageContext();
CGImageRelease(imageRef);
}
对于其他提示,看看我的答案http://stackoverflow.com/questions/19042819/creating-image-with-in-the-frame-of-a-rectangle-placed-on-a-uiimageview – iPatel
顺便说一句,你有一个调用'UIGraphicsBeginImageContext'和两个调用'UIGraphicsEndImageContext'。您可能想要删除第二个电话。 – Rob