iphone - iPhone 上的线程绘图

标签 iphone cocoa-touch multithreading quartz-2d nsoperation

苹果文档指出,一般来说 Quartz2D 是 thread-safe 。然而,当在 NSOperation 期间绘制到图像上下文时,我遇到了崩溃(EXC_BAD_ACCESS)。

这是我当前的设置:

UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing code
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我怀疑崩溃与当前上下文有关,因为 UIGraphicsGetCurrentContext 文档指出需要从 main thread 调用它。 。它是否正确?还有其他方法获取图像上下文吗?

最佳答案

各种 UIGraphics 函数大多只是围绕较低级别函数的便捷方法。阅读 CGGraphicsContext 以及如何创建您自己的;该文档非常有帮助。

关于iphone - iPhone 上的线程绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1516944/

相关文章:

ios - Swift:如何重写 scrollView 的方法?

iphone - 绘制到 GPU 的图形的屏幕截图?

java - 以较小的内存占用量执行数百万次 Runnable

ios - 将刷新数据的调用排队的好方法是什么?

iphone - 如何删除 iCloud 文件?

iphone - 反调试怎么处理库打补丁?

iphone - 在 iphone 应用程序中嵌入 HTML 页面的最佳框架?

iphone - 如何在 iOS 中加密 mp3 文件

c++ - 通过线程分配 for 循环迭代

arrays - 如果数组是值类型并因此被复制,那么它们为什么不是线程安全的?