2回目に画像を回転しようとすると、アプリにバグが発生する理由がわかりません
-(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
しかし、2回目では:
2012-07-11 17:22:55.253 meshtiles[3330:707] *** -[UIImage size]: message sent to deallocated instance 0x8452560
この場合のサポートがあれば、助けてください