Skip to content

Commit

Permalink
fixed UIImage to load localized versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Silverman committed Oct 30, 2012
1 parent 76985c4 commit 2b79d2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions UIKit/Classes/UIImage.m
Expand Up @@ -39,14 +39,14 @@ @implementation UIImage
+ (UIImage *)_imageNamed:(NSString *)name
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [[bundle resourcePath] stringByAppendingPathComponent:name];
NSString *path = [bundle pathForResource:name ofType:nil];
UIImage *img = [self imageWithContentsOfFile:path];

if (!img) {
// if nothing is found, try again after replacing any underscores in the name with dashes.
// I don't know why, but UIKit does something similar. it probably has a good reason and it might not be this simplistic, but
// for now this little hack makes Ramp Champ work. :)
path = [[[bundle resourcePath] stringByAppendingPathComponent:[[name stringByDeletingPathExtension] stringByReplacingOccurrencesOfString:@"_" withString:@"-"]] stringByAppendingPathExtension:[name pathExtension]];
path = [bundle pathForResource:[[name stringByDeletingPathExtension] stringByReplacingOccurrencesOfString:@"_" withString:@"-"] ofType:[name pathExtension]];
img = [self imageWithContentsOfFile:path];
}

Expand Down

0 comments on commit 2b79d2d

Please sign in to comment.