ios - 使用 UIGraphicsGetImageFromCurrentImageContext 时如何修复因内存问题而终止?

标签 ios objective-c ipad core-graphics automatic-ref-counting

在我的绘图应用程序中,我使用 UIImage 来缓存绘图。

以下代码行导致内存问题:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
self.cacheImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

如何在不导致内存泄漏的情况下使用 UIGraphicsGetImageFromCurrentImageContext

任何帮助将不胜感激。提前致谢。

最佳答案

使用这个可能对你有帮助。 它对我的情况有帮助

 @autoreleasepool {
  // Write your code here    
 }

关于ios - 使用 UIGraphicsGetImageFromCurrentImageContext 时如何修复因内存问题而终止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45343546/

相关文章:

ios - 自 iOS 10 以来,带有 startMonitoringForRegion 的 CCLocation 不再工作

Objective-C/CGI 我唯一的选择?

iphone - NSMutableDictionary设置值在iOS 5上崩溃

ios - 收到 APNS 通知但不显示

Jquery Animate ScrollLeft 在 iPad 上不起作用

ios - 无法找到 NSNotification 的发件人

ios - 如何刷新表格 View 但禁用弹跳?

iphone - 以嵌入式 html 播放视频时,如何使用证书不正确的 https 连接播放视频 URL

ios - 一旦我在 View Controller 中调整 Storyboard View 的大小,我的其他 View 就会消失

objective-c - 使用自定义字体计算 NSString 的高度