How can CCSprite load ImageURL

78 Views Asked by At
UIImageView *imageView = [[UIImageView alloc] init];
[ImageViewHelper setImageURL:productInfo.ImageUrl forImageView:imageView];
CCSprite *imageSprite = [CCSprite spriteWithCGImage:imageView.image.CGImage key:productInfo.ImageUrl];

setImageURL: forImageView: is a multithreaded way, and when I perform to the third step, the imageView does not get loaded successfully, because it's done on a separate queue via multi-threading, but imageSprite needs the imageView.image to be valid.

1

There are 1 best solutions below

0
Unheilig On BEST ANSWER

If you are getting the data from a back ground thread, please try getting back onto the main queue while loading the image sprite:

dispatch_sync(dispatch_get_main_queue(), ^{});