Skip to content

Commit

Permalink
Merge pull request #80 from NYTimes/cdz/64-75-image-loading
Browse files Browse the repository at this point in the history
Load bar button item images from the correct bundle
  • Loading branch information
Twigz committed Oct 30, 2015
2 parents 5751193 + 07eedb4 commit ceec2bd
Show file tree
Hide file tree
Showing 17 changed files with 739 additions and 625 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
NYTPhotoViewer: d74401f7cf0b679a1763414d114eb5c81f5a1db8
NYTPhotoViewer: d852216690e0496bf925abab1350be0f547d93bd
OCMock: 28def049ef47f996b515a8eeea958be7ccab2dbb

COCOAPODS: 0.38.2

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

8 changes: 7 additions & 1 deletion Example/Pods/Local Podspecs/NYTPhotoViewer.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,239 changes: 678 additions & 561 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion NYTPhotoViewer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.source_files = 'Pod/Classes/**/*'
s.resources = 'Pod/Assets/**/*'
s.ios.resource_bundle = { s.name => ['Pod/Assets/ios/*.png'] }

s.frameworks = 'UIKit', 'Foundation'
end
3 changes: 2 additions & 1 deletion Pod/Classes/ios/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "NYTPhoto.h"
#import "NYTPhotosOverlayView.h"
#import "NYTPhotoCaptionView.h"
#import "NSBundle+NYTPhotoViewer.h"

NSString * const NYTPhotosViewControllerDidNavigateToPhotoNotification = @"NYTPhotosViewControllerDidNavigateToPhotoNotification";
NSString * const NYTPhotosViewControllerWillDismissNotification = @"NYTPhotosViewControllerWillDismissNotification";
Expand Down Expand Up @@ -172,7 +173,7 @@ - (void)commonInitWithPhotos:(NSArray *)photos initialPhoto:(id <NYTPhoto>)initi

// iOS 7 has an issue with constraints that could evaluate to be negative, so we set the width to the margins' size.
_overlayView = [[NYTPhotosOverlayView alloc] initWithFrame:CGRectMake(0, 0, NYTPhotoCaptionViewHorizontalMargin * 2.0, 0)];
_overlayView.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"NYTPhotoViewerCloseButtonX"] landscapeImagePhone:[UIImage imageNamed:@"NYTPhotoViewerCloseButtonXLandscape"] style:UIBarButtonItemStylePlain target:self action:@selector(doneButtonTapped:)];
_overlayView.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"NYTPhotoViewerCloseButtonX" inBundle:[NSBundle nyt_photoViewerResourceBundle] compatibleWithTraitCollection:nil] landscapeImagePhone:[UIImage imageNamed:@"NYTPhotoViewerCloseButtonXLandscape" inBundle:[NSBundle nyt_photoViewerResourceBundle] compatibleWithTraitCollection:nil] style:UIBarButtonItemStylePlain target:self action:@selector(doneButtonTapped:)];
_overlayView.leftBarButtonItem.imageInsets = NYTPhotosViewControllerCloseButtinImageInsets;
_overlayView.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionButtonTapped:)];

Expand Down
15 changes: 15 additions & 0 deletions Pod/Classes/ios/Resource Loading/NSBundle+NYTPhotoViewer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSBundle+NYTPhotoViewer.h
// NYTPhotoViewer
//
// Created by Chris Dzombak on 10/16/15.
//
//

@import Foundation;

@interface NSBundle (NYTPhotoViewer)

+ (instancetype)nyt_photoViewerResourceBundle;

@end
23 changes: 23 additions & 0 deletions Pod/Classes/ios/Resource Loading/NSBundle+NYTPhotoViewer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// NSBundle+NYTPhotoViewer.m
// NYTPhotoViewer
//
// Created by Chris Dzombak on 10/16/15.
//
//

#import "NSBundle+NYTPhotoViewer.h"

@implementation NSBundle (NYTPhotoViewer)

+ (instancetype)nyt_photoViewerResourceBundle {
static NSBundle *resourceBundle = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *resourceBundlePath = [[NSBundle mainBundle] pathForResource:@"NYTPhotoViewer" ofType:@"bundle"];
resourceBundle = [self bundleWithPath:resourceBundlePath];
});
return resourceBundle;
}

@end

0 comments on commit ceec2bd

Please sign in to comment.