Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Update how image resources are loaded/validated
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbunny committed May 22, 2017
1 parent de5d449 commit eeb0ab4
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ - (void)commonInit

// setup logo bug
//
UIImage *logo = [MGLMapView resourceImageNamed:@"mapbox.png"];
UIImage *logo = [MGLMapView resourceImageNamed:@"mapbox"];
_logoView = [[UIImageView alloc] initWithImage:logo];
_logoView.accessibilityTraits = UIAccessibilityTraitStaticText;
_logoView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"LOGO_A11Y_LABEL", nil, nil, @"Mapbox", @"Accessibility label");
Expand Down Expand Up @@ -616,7 +616,7 @@ - (void)createGLView

- (UIImage *)compassImage
{
UIImage *scaleImage = [MGLMapView resourceImageNamed:@"Compass.png"];
UIImage *scaleImage = [MGLMapView resourceImageNamed:@"Compass"];
UIGraphicsBeginImageContextWithOptions(scaleImage.size, NO, [UIScreen mainScreen].scale);
[scaleImage drawInRect:{ CGPointZero, scaleImage.size }];

Expand Down Expand Up @@ -5290,18 +5290,17 @@ - (void)updateCompass

+ (UIImage *)resourceImageNamed:(NSString *)imageName
{
NSString *extension = imageName.pathExtension.length ? imageName.pathExtension : @"png";
NSBundle *bundle = [NSBundle mgl_frameworkBundle];
NSString *path = [bundle pathForResource:imageName.stringByDeletingPathExtension
ofType:extension
inDirectory:bundle.mgl_resourcesDirectory];
if ( ! path)
UIImage *image = [UIImage imageNamed:imageName
inBundle:[NSBundle mgl_frameworkBundle]
compatibleWithTraitCollection:nil];

if ( ! image)
{
[NSException raise:@"Resource not found" format:
@"The resource named “%@” could not be found in the Mapbox framework bundle.", imageName];
}

return [UIImage imageWithContentsOfFile:path];
return image;
}

- (BOOL)isFullyLoaded
Expand Down

0 comments on commit eeb0ab4

Please sign in to comment.