Skip to content

Commit

Permalink
iPad compatibility fixes, added shape view
Browse files Browse the repository at this point in the history
  • Loading branch information
phallguy committed Oct 8, 2010
1 parent dd2710a commit d5cd872
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 9 deletions.
9 changes: 7 additions & 2 deletions Classes/GDataXML+PFXml.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ -(NSString *) stringValueOfElementNamed: (NSString *) name

-(CLLocationCoordinate2D) coordinateFromElement
{
return CLLocationCoordinate2DMake( [self doubleValueOfAttributeNamed: @"lat"], [self doubleValueOfAttributeNamed: @"long"] );

CLLocationCoordinate2D coord = { [self doubleValueOfAttributeNamed: @"lat"], [self doubleValueOfAttributeNamed: @"long"] };

return coord;
}

-(CLLocationCoordinate2D) coordinateFromElementName: (NSString*) name
Expand All @@ -81,7 +84,9 @@ -(CLLocationCoordinate2D) coordinateFromElementName: (NSString*) name
if( element == nil )
return CLLocationCoordinate2DMake( 0, 0 );

return CLLocationCoordinate2DMake( [element doubleValueOfAttributeNamed: @"lat"], [element doubleValueOfAttributeNamed: @"long"] );
CLLocationCoordinate2D coord = { [element doubleValueOfAttributeNamed: @"lat"], [element doubleValueOfAttributeNamed: @"long"] };

return coord;
}


Expand Down
7 changes: 6 additions & 1 deletion Classes/PFImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ -(UIImage*) imageNamed: (NSString *) imageName forSize: (CGSize) size
return nil;
}

if( original.size.width * original.scale == size.width && original.size.height * original.scale == size.height )
CGFloat originalScale = 1.0;
if( [original respondsToSelector: @selector(scale)] )
originalScale = original.scale;


if( original.size.width * originalScale == size.width && original.size.height * originalScale == size.height )
{
[[NSFileManager defaultManager] copyItemAtPath: resolved toPath: cacheName error: NULL];
}
Expand Down
16 changes: 16 additions & 0 deletions Classes/UIColor+PFExtensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// UIColor+PFExtensions.h
// Pants-Framework
//
// Created by Paul Alexander on 10/8/10.
// Copyright (c) 2010 n/a. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface UIColor (PFExtensions)

+(UIColor *) random;

@end
19 changes: 19 additions & 0 deletions Classes/UIColor+PFExtensions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UIColor+PFExtensions.m
// Pants-Framework
//
// Created by Paul Alexander on 10/8/10.
// Copyright (c) 2010 n/a. All rights reserved.
//

#import "UIColor+PFExtensions.h"


@implementation UIColor (PFExtensions)

+(UIColor *) random
{
return [UIColor colorWithRed: ( arc4random() % 255 ) / 255.0 green: ( arc4random() % 255 ) / 255.0 blue: ( arc4random() % 255 ) / 255.0 alpha: 1];
}

@end
22 changes: 22 additions & 0 deletions Classes/Views/PFShapeView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// PFShapeView.h
// Pants-Framework
//
// Created by Paul Alexander on 10/7/10.
// Copyright (c) 2010 n/a. All rights reserved.
//

#import <UIKit/UIKit.h>
@class CAShapeLayer;

@interface PFShapeView : UIView
{
@private
CAShapeLayer * shape;
}

@property( nonatomic, readonly ) CAShapeLayer * shape;

-(void) setPoints: (NSArray *) points;

@end
65 changes: 65 additions & 0 deletions Classes/Views/PFShapeView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// PFShapeView.m
// Pants-Framework
//
// Created by Paul Alexander on 10/7/10.
// Copyright (c) 2010 n/a. All rights reserved.
//

#import "PFShapeView.h"
#import <QuartzCore/QuartzCore.h>


@implementation PFShapeView

@synthesize shape;

-(id) initWithFrame: (CGRect) frame
{
if( self = [super initWithFrame:frame] )
{
shape = [[CAShapeLayer alloc] init];
shape.bounds = CGRectMake( 0, 0, CGRectGetWidth( frame ), CGRectGetHeight( frame ) );
shape.position = CGPointMake( CGRectGetWidth( frame ) / 2, CGRectGetHeight( frame ) / 2 );
shape.fillRule = kCAFillRuleNonZero;

[self.layer addSublayer: shape];
}

return self;
}

-(void) dealloc
{
SafeRelease( shape );

[super dealloc];
}

-(void) setPoints: (NSArray *) points
{
CGMutablePathRef path = CGPathCreateMutable();

for( int ix = 0; ix < points.count; ix++ )
{
NSValue * val = [points objectAtIndex: ix];
CGPoint point = [val CGPointValue];

if( ix == 0 )
CGPathMoveToPoint( path, NULL, point.x, point.y );
else
CGPathAddLineToPoint( path, NULL, point.x, point.y );
}

CGPathCloseSubpath( path );

shape.path = path;

CGPathRelease( path );

}




@end
24 changes: 20 additions & 4 deletions Pants-Framework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
DAAB70C1123612BD007A7A17 /* PFCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = DAAB70BD123612BD007A7A17 /* PFCommon.m */; };
DAAC0C3112445F7600ED8F47 /* GDataXMLNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DAAC0C2F12445F7600ED8F47 /* GDataXMLNode.h */; };
DAAC0C3212445F7600ED8F47 /* GDataXMLNode.m in Sources */ = {isa = PBXBuildFile; fileRef = DAAC0C3012445F7600ED8F47 /* GDataXMLNode.m */; };
DAB96A53125F04A6007F6AA5 /* UIColor+PFExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = DAB96A51125F04A6007F6AA5 /* UIColor+PFExtensions.h */; };
DAB96A54125F04A6007F6AA5 /* UIColor+PFExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB96A52125F04A6007F6AA5 /* UIColor+PFExtensions.m */; };
DABFE264125EF3FB00F93C13 /* PFShapeView.h in Headers */ = {isa = PBXBuildFile; fileRef = DABFE262125EF3FB00F93C13 /* PFShapeView.h */; };
DABFE265125EF3FB00F93C13 /* PFShapeView.m in Sources */ = {isa = PBXBuildFile; fileRef = DABFE263125EF3FB00F93C13 /* PFShapeView.m */; };
DACE0732125E8EFB00173EF0 /* PFSpringLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = DACE0730125E8EFB00173EF0 /* PFSpringLayout.h */; };
DACE0733125E8EFB00173EF0 /* PFSpringLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = DACE0731125E8EFB00173EF0 /* PFSpringLayout.m */; };
DACE073A125E8F3B00173EF0 /* NSString+PFExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = DACE0738125E8F3B00173EF0 /* NSString+PFExtensions.h */; };
Expand Down Expand Up @@ -77,6 +81,10 @@
DAAB70BD123612BD007A7A17 /* PFCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PFCommon.m; path = Classes/PFCommon.m; sourceTree = "<group>"; };
DAAC0C2F12445F7600ED8F47 /* GDataXMLNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDataXMLNode.h; path = Classes/GDataXMLNode.h; sourceTree = "<group>"; };
DAAC0C3012445F7600ED8F47 /* GDataXMLNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GDataXMLNode.m; path = Classes/GDataXMLNode.m; sourceTree = "<group>"; };
DAB96A51125F04A6007F6AA5 /* UIColor+PFExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+PFExtensions.h"; path = "Classes/UIColor+PFExtensions.h"; sourceTree = "<group>"; };
DAB96A52125F04A6007F6AA5 /* UIColor+PFExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+PFExtensions.m"; path = "Classes/UIColor+PFExtensions.m"; sourceTree = "<group>"; };
DABFE262125EF3FB00F93C13 /* PFShapeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFShapeView.h; sourceTree = "<group>"; };
DABFE263125EF3FB00F93C13 /* PFShapeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFShapeView.m; sourceTree = "<group>"; };
DACE0730125E8EFB00173EF0 /* PFSpringLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFSpringLayout.h; sourceTree = "<group>"; };
DACE0731125E8EFB00173EF0 /* PFSpringLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFSpringLayout.m; sourceTree = "<group>"; };
DACE0738125E8F3B00173EF0 /* NSString+PFExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+PFExtensions.h"; path = "Classes/NSString+PFExtensions.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -141,6 +149,8 @@
08FB77AEFE84172EC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
DAB96A51125F04A6007F6AA5 /* UIColor+PFExtensions.h */,
DAB96A52125F04A6007F6AA5 /* UIColor+PFExtensions.m */,
DACE0738125E8F3B00173EF0 /* NSString+PFExtensions.h */,
DACE0739125E8F3B00173EF0 /* NSString+PFExtensions.m */,
DADB63D31249963400B681CC /* UIImage+Resize.h */,
Expand Down Expand Up @@ -177,6 +187,8 @@
DAFB36871235A90F0008E7DB /* Views */ = {
isa = PBXGroup;
children = (
DABFE262125EF3FB00F93C13 /* PFShapeView.h */,
DABFE263125EF3FB00F93C13 /* PFShapeView.m */,
DACE0730125E8EFB00173EF0 /* PFSpringLayout.h */,
DACE0731125E8EFB00173EF0 /* PFSpringLayout.m */,
DA147A9712558315009F6E1C /* PFContainerView.h */,
Expand Down Expand Up @@ -229,6 +241,8 @@
DA147A9912558315009F6E1C /* PFContainerView.h in Headers */,
DACE0732125E8EFB00173EF0 /* PFSpringLayout.h in Headers */,
DACE073A125E8F3B00173EF0 /* NSString+PFExtensions.h in Headers */,
DABFE264125EF3FB00F93C13 /* PFShapeView.h in Headers */,
DAB96A53125F04A6007F6AA5 /* UIColor+PFExtensions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -301,6 +315,8 @@
DA147A9A12558315009F6E1C /* PFContainerView.m in Sources */,
DACE0733125E8EFB00173EF0 /* PFSpringLayout.m in Sources */,
DACE073B125E8F3B00173EF0 /* NSString+PFExtensions.m in Sources */,
DABFE265125EF3FB00F93C13 /* PFShapeView.m in Sources */,
DAB96A54125F04A6007F6AA5 /* UIColor+PFExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -321,7 +337,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Pants_Framework_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
HEADER_SEARCH_PATHS = /usr/include/libxml2;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = Pants_Framework;
Expand All @@ -337,7 +353,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Pants_Framework_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
HEADER_SEARCH_PATHS = /usr/include/libxml2;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = Pants_Framework;
Expand All @@ -350,7 +366,7 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
Expand All @@ -365,7 +381,7 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.1.3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
<integer>2</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
2 changes: 1 addition & 1 deletion Pants_Framework_Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Fix LLVM 2.0 compilation for simulator in xcode
#include "TargetConditionals.h"

#if TARGET_IPHONE_SIMULATOR
#if TARGET_IPHONE_SIMULATOR && ! __IPHONE_OS_VERSION_MIN_REQUIRED
#define __IPHONE_OS_VERSION_MIN_REQUIRED 030103
#endif

Expand Down

0 comments on commit d5cd872

Please sign in to comment.