拍照后我尝试剪切图像。这在非视网膜设备上运行良好。但在 Retina 设备上收到内存警告。我认为在我注释掉图像时剪切图像时存在一些内存泄漏,没有问题。
代码:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
CGSize imageSize = image.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat newDimension = 2360;
CGFloat widthOffset = 20 * [[UIScreen mainScreen] scale];
CGFloat heightOffset = 135 * [[UIScreen mainScreen] scale];
UIGraphicsBeginImageContextWithOptions(CGSizeMake(newDimension, newDimension), NO, 0.);
[image drawAtPoint:CGPointMake(-widthOffset, -heightOffset)
blendMode:kCGBlendModeCopy
alpha:1.];
productImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self dismissViewControllerAnimated:NO completion:nil];
...
}
第一次拍照后,我收到内存警告但没有崩溃。当我尝试重新打开相机时,应用程序崩溃了。有人可以帮帮我吗?谢谢