ios - CGContext清除警告

标签 ios cgimage

我在使用 CGImageDestinationFinalize 时遇到 iOS 问题。我将在 CGImageDestinationRef 上调用 CGImageDestinationFinalize,我将收到以下警告

Error: The function `CGContextClear' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.

查看 Instruments,当我调用 CGImageDestinationFinalize 时,我的内存使用量猛增(有时会高到崩溃)。我不确定是否应归咎于此问题,但我已将其隔离为 CGImageDestinationFinalize 的问题

关于使用什么来避免调用 CGContextClear 有什么建议吗?或者如何使用 CGImageDestinationFinalize 减少内存使用量?

最佳答案

我会明确地说它与 CGContextClear 有关。它会保留您正在绘制的任何内容。虽然您的上下文没有被清除或释放,但它会将在该上下文中定义的元素保留在内存中。您使用的是哪个版本的 iOS?
我很确定 CGContextClear 不适用于 iOS 6 及更高版本。

如果您查看文档,您会注意到 CGContextClear 不再出现 https://developer.apple.com/library/ios/DOCUMENTATION/GraphicsImaging/Reference/CGContext/Reference/reference.html

寻找可能对您的目的有帮助的 CGContextClearRect

关于ios - CGContext清除警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13740550/

相关文章:

ios - 如何让 UITableView 正确重新加载?

ios - Swift 协议(protocol)相关类型是否有使用 `=` 与 `:` 的信息?

使用 firebase 的 iOS 订阅 server_to_server 通知

ios - 使用 AVFoundation 混合图像和视频

ios - 使用 UIGraphics 和 CGI​​mage 从 UIImage 创建新图像时,颜色略有不同

ios - 手机重启后 iBeacon 监控/测距

ios - NSFetchedresultscontroller 与 tableview 插入新部分崩溃

ios - 将图像转换为 CGImage 时丢失图像方向

ios - 从 ALAssetRepresentation 生成自定义缩略图

objective-c - 正确裁剪从照片库中获取的图像