【发布时间】:2015-02-09 17:11:29
【问题描述】:
我正在绘制到自动释放池内的 ImageContext 以控制我的内存占用,并从自动释放池内返回图像。我在这个调用中发生了崩溃,我想知道它是否是由于调用函数使用之前在自动释放池中释放的图像引起的。这是我的代码:
-( UIImage *) imageRepFromShapes
{
CGRect sheetDisplayView = [ UIScreen mainScreen ].bounds;
@autoreleasepool {
UIGraphicsBeginImageContextWithOptions( boundingRect_m.size, NO, 0.0 );
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
for ( Shape *shape in arryOfShapes ) {
[ shape drawShape ];
}
UIGraphicsPopContext();
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
}
另一个问题是我在这个调用中是否需要 UIGraphicsPushContext 和 UIGraphicsPopContext ,它们是否在正确的位置。 我希望能澄清这一点。 谢谢
雷扎
【问题讨论】:
-
请发布您的崩溃日志,谢谢。
-
这是很少发生的情况之一,实际上只有一次,并且由于我在开发方案中启用了僵尸,它只是在调用中停止了。这就是为什么我不确定是电话还是其他原因。由于我启用了僵尸,我希望如果它是一个错误,它应该总是在调用中停止,但它不会
标签: ios objective-c uiimage