Created
May 16, 2012 15:58
-
-
Save odrobnik/2711594 to your computer and use it in GitHub Desktop.
Force decompression of UIImage on background queue before setting on UIImageView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_queue_t queue = dispatch_queue_create("PlusFlickrPhotoView Queue", DISPATCH_QUEUE_CONCURRENT); | |
dispatch_async(queue, ^{ | |
// force decompress of image | |
UIGraphicsBeginImageContext(CGSizeMake(1, 1)); | |
[image drawAtPoint:CGPointZero]; | |
UIGraphicsEndImageContext(); | |
// set the image on main thread | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
_imageView.image = image; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment