我将非常简短:
我正在用drawrect和NSBezierPath绘制线条。
为了绘制这些线,我使用了for循环。
现在,由于循环需要很多秒,所以我尝试使用NSProgresIndicator来显示进度,并在我使用dispatch_async &queue的循环中更新它。ProgressIndicator更新,但没有绘制任何内容。如果不使用队列,则绘制行,但指示符在周期结束时更新。
我做错什么了?
错误:
<Error>: CGContextRestoreGState: invalid context 0x0.
This is a serious error.
This application, or a library it uses, is using an invalid context
and is thereby
contributing to an overall degradation of system stability and reliability.
This notice is a courtesy: please fix this problem.
It will become a fatal error in an upcoming update.// SAMPLE OF CODE
dispatch_queue_t myQueue = dispatch_queue_create("my queue", NULL);
dispatch_async(myQueue, ^
{
for (int i = 1; i <= 200; i++) {
dispatch_async(dispatch_get_main_queue(), ^{
[istance set_progress:i];
//This sets the progress, but bezierPath doesn't work
});
//Bezier already alloc & init
[my_path moveToPoint....]
[my_path lineToPoint....]
[my_path stroke]
}
});发布于 2014-04-25 20:58:43
通常,您不应该在后台线程或队列上绘图。
有关多线程绘图的信息,请阅读此文档。跳到“绘图限制”
https://stackoverflow.com/questions/23230577
复制相似问题