我不知道为什么我的应用程序在第二次尝试旋转图像时出现错误
-(UIImage *)rotateImage:(UIImage *)image{
// calculate the size of the rotated view's containing box for our drawing space
CGSize rotatedSize = image.size;
// Create the bitmap context
UIGraphicsBeginImageContext(rotatedSize);
CGContextRef bitmap = UIGraphicsGetCurrentContext();
// Move the origin to the middle of the image so we will rotate and scale around the center.
CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
// // Rotate the image context
CGContextRotateCTM(bitmap, DegreesToRadians(90));
// Now, draw the rotated/scaled image into the context
CGContextScaleCTM(bitmap, 1.0, -1.0);
CGContextDrawImage(bitmap, CGRectMake(-image.size.width / 2, -image.size.height / 2, image.size.width, image.size.height), image.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
我通过以下方式调用此函数:
NSLog(@"%f %f",rotatedOriginImage.size.width,rotatedOriginImage.size.height);
rotatedOriginImage = [self rotateImage:rotatedOriginImage];
在第一次登录时:
2012-07-11 17:22:50.825 meshtiles[3330:707] 600.000000 600.000000
但在第二次:
2012-07-11 17:22:55.253 meshtiles[3330:707] *** -[UIImage size]: message sent to deallocated instance 0x8452560
对此案有任何支持,请帮助我