Created
September 16, 2014 18:42
-
-
Save nonamelive/2386f10be807cab78cb2 to your computer and use it in GitHub Desktop.
Fix for [UIImage initWithContentsOfFile] on iOS 8 not loading correct images
This file contains hidden or 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
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