UIImage* i开发者_Python百科mg = [UIImage imageWithCGImage: imageRef];
can be done in main-thread only.. bah..Now all my image create functions which are to be run in background thread has to be modified.
Question is how should I change the above line.Usual steps of creating image were as below.
CGImageRef imageRef = CGBitmapContextCreateImage(context);
UIImage* img = [UIImage imageWithCGImage: imageRef];
CGImageRelease(imageRef);
CGContextRelease(context);
return img;
If performSelector returned a value, it would be rather easy.
But it's not. Since this seems rather common requirement, I wonder if there are preferable practice of doing this.Thank you
UIImage* img = [UIImage imageWithCGImage: imageRef]; can be done in main-thread only.. bah..
Only if you want to target iOS 3.x devices. Starting from iOS 4, UIImage
became thread-safe. If you need to run on iOS 3, typical behaviour would be to pass your CGImageRef back to the main thread, and have the imageWithCGImage
method run there.
精彩评论