Skip to content

Commit

Permalink
Merge branch 'release-1.5.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Jul 27, 2015
2 parents 1a1dc73 + 1987c41 commit 21ad8e3
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 29 deletions.
67 changes: 50 additions & 17 deletions Core/Source/DTLoupeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ @implementation DTLoupeView

// Draws cross hairs for debugging
BOOL _drawDebugCrossHairs;

// the resource bundle
NSBundle *_resourceBundle;
}


Expand Down Expand Up @@ -110,14 +113,6 @@ - (id)init

if (self)
{
// make sure that resource bundle is present
NSString *resourceBundlePath = [[NSBundle mainBundle] pathForResource:@"DTLoupe" ofType:@"bundle"];

if (!resourceBundlePath)
{
NSLog(@"DTLoupe.bundle is missing from app bundle. Please make sure that you include it in your app's resources");
};

self.contentMode = UIViewContentModeCenter;
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
Expand Down Expand Up @@ -364,32 +359,70 @@ - (void)adjustBaseViewIfNecessary
}
}

- (NSBundle *)_resourceBundle
{
if (!_resourceBundle)
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *resourceBundlePath = [bundle pathForResource:@"DTLoupe" ofType:@"bundle"];

if (!resourceBundlePath)
{
// try to find it in main bundle instead
bundle = [NSBundle mainBundle];
resourceBundlePath = [bundle pathForResource:@"DTLoupe" ofType:@"bundle"];
}

NSAssert(resourceBundlePath, @"DTLoupe.bundle is missing from app bundle. Please make sure that you include it in your app's resources or embed the DTRichTextEditor.framework");

_resourceBundle = [NSBundle bundleWithPath:resourceBundlePath];
}

return _resourceBundle;
}

- (UIImage *)_imageNamedFromResourceBundle:(NSString *)name
{
NSBundle *resourceBundle = [self _resourceBundle];

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000
// this method works >= iOS 8 and is the preferred way to get images from bundles
UIImage *image = [UIImage imageNamed:name inBundle:resourceBundle compatibleWithTraitCollection:nil];
#else
// classic method to get images from bundles
NSString *imagePath = [resourceBundle pathForResource:name ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
#endif

return image;
}

- (void)setImagesForStyle:(DTLoupeStyle)style
{
switch (style)
{
case DTLoupeStyleCircle:
{
self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-lo.png"];
self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-mask.png"];
self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-loupe-hi.png"];
self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-loupe-lo"];
self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-loupe-mask"];
self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-loupe-hi"];

break;
}
case DTLoupeStyleRectangle:
{
self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-lo-stemless.png"];
self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-mask.png"];
self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-hi.png"];
self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-lo-stemless"];
self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-mask"];
self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-hi"];

break;
}

case DTLoupeStyleRectangleWithArrow:
{
self.loupeFrameBackgroundImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-lo.png"];
self.loupeFrameMaskImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-mask.png"];
self.loupeFrameImage = [UIImage imageNamed:@"DTLoupe.bundle/kb-magnifier-ranged-hi.png"];
self.loupeFrameBackgroundImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-lo"];
self.loupeFrameMaskImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-mask"];
self.loupeFrameImage = [self _imageNamedFromResourceBundle:@"kb-magnifier-ranged-hi"];

break;
}
Expand Down
2 changes: 1 addition & 1 deletion DTLoupe.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DTLoupe'
spec.version = '1.5.6'
spec.version = '1.5.7'
spec.platform = :ios, '4.3'
spec.license = 'BSD'
spec.source = { :git => 'https://github.com/Cocoanetics/DTLoupe.git', :tag => spec.version.to_s }
Expand Down
107 changes: 96 additions & 11 deletions DTLoupe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,14 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = YES;
PUBLIC_HEADERS_FOLDER_PATH = DTLoupe;
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -525,6 +526,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PUBLIC_HEADERS_FOLDER_PATH = DTLoupe;
SDKROOT = iphoneos;
};
name = Release;
Expand Down Expand Up @@ -559,7 +561,42 @@
};
name = Release;
};
A7D8FEED14E1693300BF8CCD /* Debug */ = {
A79C2FE41B60DC7700E5491A /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "COVERAGE=1";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = YES;
PUBLIC_HEADERS_FOLDER_PATH = DTLoupe;
SDKROOT = iphoneos;
};
name = Coverage;
};
A79C2FE51B60DC7700E5491A /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Demo/Demo-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "Demo/Demo-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Coverage;
};
A79C2FE61B60DC7700E5491A /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
Expand All @@ -573,16 +610,64 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Core/DTLoupe-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DTLoupe;
SKIP_INSTALL = YES;
};
name = Coverage;
};
A79C2FE71B60DC7700E5491A /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Resource Bundle/Resource Bundle-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "Core/Resources/ResourceBundle-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = DTLoupe;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
WRAPPER_EXTENSION = bundle;
};
name = Coverage;
};
A79C2FE81B60DC7700E5491A /* Coverage */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Coverage;
};
A7D8FEED14E1693300BF8CCD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = (
"$(ARCHS_STANDARD)",
armv7s,
);
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/Static_Library.dst;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Core/DTLoupe-Prefix.pch";
GCC_THUMB_SUPPORT = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DTLoupe;
PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupeView;
SKIP_INSTALL = YES;
};
name = Debug;
Expand All @@ -605,7 +690,6 @@
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DTLoupe;
PUBLIC_HEADERS_FOLDER_PATH = ../../DTLoupeView;
SKIP_INSTALL = YES;
VALIDATE_PRODUCT = YES;
};
Expand All @@ -621,10 +705,6 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Resource Bundle/Resource Bundle-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "Core/Resources/ResourceBundle-Info.plist";
Expand Down Expand Up @@ -681,6 +761,7 @@
isa = XCConfigurationList;
buildConfigurations = (
0F01D8B113B248CB00419BD7 /* Debug */,
A79C2FE41B60DC7700E5491A /* Coverage */,
0F01D8B213B248CB00419BD7 /* Release */,
);
defaultConfigurationIsVisible = 0;
Expand All @@ -690,6 +771,7 @@
isa = XCConfigurationList;
buildConfigurations = (
0F01D8B413B248CB00419BD7 /* Debug */,
A79C2FE51B60DC7700E5491A /* Coverage */,
0F01D8B513B248CB00419BD7 /* Release */,
);
defaultConfigurationIsVisible = 0;
Expand All @@ -699,6 +781,7 @@
isa = XCConfigurationList;
buildConfigurations = (
A7D8FEED14E1693300BF8CCD /* Debug */,
A79C2FE61B60DC7700E5491A /* Coverage */,
A7D8FEEE14E1693300BF8CCD /* Release */,
);
defaultConfigurationIsVisible = 0;
Expand All @@ -708,6 +791,7 @@
isa = XCConfigurationList;
buildConfigurations = (
A7D8FF6514E17A6600BF8CCD /* Debug */,
A79C2FE71B60DC7700E5491A /* Coverage */,
A7D8FF6614E17A6600BF8CCD /* Release */,
);
defaultConfigurationIsVisible = 0;
Expand All @@ -717,6 +801,7 @@
isa = XCConfigurationList;
buildConfigurations = (
A7DF6EF0173A9646004F623B /* Debug */,
A79C2FE81B60DC7700E5491A /* Coverage */,
A7DF6EF1173A9646004F623B /* Release */,
);
defaultConfigurationIsVisible = 0;
Expand Down
4 changes: 4 additions & 0 deletions Documentation/Change Log-template.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Change Log

This is the history of version updates.

Version 1.5.7

- ADDED: DTLoupe resource bundle can now also be in framework resources

Version 1.5.6

- FIXED: Invalid layer geometry might cause crash
Expand Down

0 comments on commit 21ad8e3

Please sign in to comment.