开发者

iPhone - using the current Quartz context from a thread

I have a Quartz context declared in the main loop as

U开发者_开发知识库IGraphicsBeginImageContext(mySize);
ctx = UIGraphicsGetCurrentContext();
// bla bla bla

This context is changing, as the user is doing stuff on the screen.

At some point in the app I need a new thread to be fired and grab what the context has, saving to a UIImageView.

on the thread I have something like

myImageView.image = UIGraphicsGetImageFromCurrentImageContext();

but this is giving me nil, as the thread is not able to know that the current context is.

How do I solve that?

thanks.


OK, it may be a kludge but you could try this

- (void) myUIGraphicsGetImageFromCurrentImageContext
    {
    myImageView.image= UIGraphicsGetImageFromCurrentImageContext();
    }

Then in your thread replace the myImageView.Image=…line with this:

   [self performSelectorOnMainThread:@selector(myUIGraphicsGetImageFromCurrentImageContext) withObject:nil waitUntilDone:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜