Skip to content

Instantly share code, notes, and snippets.

@nonamelive
Created September 16, 2014 18:42
Show Gist options
  • Save nonamelive/2386f10be807cab78cb2 to your computer and use it in GitHub Desktop.
Save nonamelive/2386f10be807cab78cb2 to your computer and use it in GitHub Desktop.
Fix for [UIImage initWithContentsOfFile] on iOS 8 not loading correct images
NSInteger scale = (int)[[UIScreen mainScreen] scale];
UIImage *image = nil;
while (scale > 0 && !image)
{
NSString *fileName = [imageName stringByAppendingString:scale > 1 ? [NSString stringWithFormat:@"@%dx", scale] : @".png"];
NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"png"];
image = [UIImage imageWithContentsOfFile:filePath];
scale--;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment