Skip to content

Commit

Permalink
Made the sample app more interesting.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirbyt committed Apr 25, 2011
1 parent f674d5d commit fc208af
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 45 deletions.
8 changes: 8 additions & 0 deletions OneFingerRotation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
6830367F13620672000E4EC3 /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6830367E13620672000E4EC3 /* RootViewController.m */; };
6830368113620701000E4EC3 /* RootView~ipad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6830368013620700000E4EC3 /* RootView~ipad.xib */; };
683036831362092B000E4EC3 /* RootView~iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 683036821362092B000E4EC3 /* RootView~iphone.xib */; };
686D53891365B04200FFF635 /* subway.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 686D53871365B04200FFF635 /* subway.jpg */; };
686D538A1365B04200FFF635 /* tower.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 686D53881365B04200FFF635 /* tower.jpg */; };
6876364713621C9E00B19700 /* KTOneFingerRotationGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6876364613621C9E00B19700 /* KTOneFingerRotationGestureRecognizer.m */; };
6876364A1362209200B19700 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 687636481362209100B19700 /* LICENSE */; };
6876364B1362209200B19700 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 687636491362209200B19700 /* README.md */; };
Expand All @@ -42,6 +44,8 @@
6830367E13620672000E4EC3 /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = "<group>"; };
6830368013620700000E4EC3 /* RootView~ipad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "RootView~ipad.xib"; sourceTree = "<group>"; };
683036821362092B000E4EC3 /* RootView~iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "RootView~iphone.xib"; sourceTree = "<group>"; };
686D53871365B04200FFF635 /* subway.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = subway.jpg; sourceTree = "<group>"; };
686D53881365B04200FFF635 /* tower.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tower.jpg; sourceTree = "<group>"; };
6876364513621C9E00B19700 /* KTOneFingerRotationGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KTOneFingerRotationGestureRecognizer.h; sourceTree = SOURCE_ROOT; };
6876364613621C9E00B19700 /* KTOneFingerRotationGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KTOneFingerRotationGestureRecognizer.m; sourceTree = SOURCE_ROOT; };
687636481362209100B19700 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
Expand Down Expand Up @@ -141,6 +145,8 @@
isa = PBXGroup;
children = (
683036731362061B000E4EC3 /* astroland.jpg */,
686D53871365B04200FFF635 /* subway.jpg */,
686D53881365B04200FFF635 /* tower.jpg */,
);
path = images;
sourceTree = "<group>";
Expand Down Expand Up @@ -203,6 +209,8 @@
683036831362092B000E4EC3 /* RootView~iphone.xib in Resources */,
6876364A1362209200B19700 /* LICENSE in Resources */,
6876364B1362209200B19700 /* README.md in Resources */,
686D53891365B04200FFF635 /* subway.jpg in Resources */,
686D538A1365B04200FFF635 /* tower.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 3 additions & 1 deletion OneFingerRotation/Classes/RootViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

}

@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) IBOutlet UIImageView *imageView1;
@property (nonatomic, retain) IBOutlet UIImageView *imageView2;
@property (nonatomic, retain) IBOutlet UIImageView *imageView3;

@end
53 changes: 44 additions & 9 deletions OneFingerRotation/Classes/RootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@

@implementation RootViewController

@synthesize imageView = imageView_;
@synthesize imageView1 = imageView1_;
@synthesize imageView2 = imageView2_;
@synthesize imageView3 = imageView3_;

- (void)dealloc
{
[imageView_ release], imageView_ = nil;

[imageView1_ release], imageView1_ = nil;
[imageView2_ release], imageView2_ = nil;
[imageView3_ release], imageView3_ = nil;
[super dealloc];
}

Expand All @@ -33,20 +38,50 @@ - (void)viewDidLoad
{
[super viewDidLoad];

// Add the one finger rotation gesture recongnizer to the
// current view. It can be added it to [self imageView]
// if we want. Just remember to the userInteractionEnabled
// flag to YES on the imageView.
//// Set #if to 1 to add the guester recognizer to the image view.
//// Set #if to 0 to add the gesture recognizer to the main view.
//#if 1
// [[self imageView] setUserInteractionEnabled:YES];
// KTOneFingerRotationGestureRecognizer *rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
// [[self imageView] addGestureRecognizer:rotation];
// [rotation release];
//#else
// KTOneFingerRotationGestureRecognizer *rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
// [[self view] addGestureRecognizer:rotation];
// [rotation release];
//#endif

// UIImageView sets userInteractionEnabled to NO by default.
[[self imageView1] setUserInteractionEnabled:YES];
[[self imageView2] setUserInteractionEnabled:YES];
[[self imageView3] setUserInteractionEnabled:YES];

KTOneFingerRotationGestureRecognizer *rotation;

KTOneFingerRotationGestureRecognizer *rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
[[self view] addGestureRecognizer:rotation];
[rotation release];

rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
[[self imageView1] addGestureRecognizer:rotation];
[rotation release];

rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
[[self imageView2] addGestureRecognizer:rotation];
[rotation release];

rotation = [[KTOneFingerRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotating:)];
[[self imageView3] addGestureRecognizer:rotation];
[rotation release];

}

- (void)viewDidUnload
{
[super viewDidUnload];
[self setImageView:nil];
[self setImageView1:nil];
[self setImageView2:nil];
[self setImageView3:nil];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
Expand All @@ -56,7 +91,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa

- (void)rotating:(KTOneFingerRotationGestureRecognizer *)recognizer
{
UIView *view = [self imageView];
UIView *view = [recognizer view];
[view setTransform:CGAffineTransformRotate([view transform], [recognizer rotation])];
}

Expand Down
Binary file added OneFingerRotation/images/subway.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OneFingerRotation/images/tower.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 114 additions & 18 deletions OneFingerRotation/xibs/RootView~ipad.xib
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,50 @@
<string key="NSFrame">{{64, 262}, {640, 480}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<reference key="NSNextKeyView" ref="218419576"/>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">astroland.jpg</string>
</object>
</object>
<object class="IBUIImageView" id="1049761250">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{108, 14}, {320, 240}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="540458593"/>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">subway.jpg</string>
</object>
</object>
<object class="IBUIImageView" id="218419576">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{465, 806}, {160, 120}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">tower.jpg</string>
</object>
</object>
</object>
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="540458593"/>
<reference key="NSNextKeyView" ref="1049761250"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC45MDE5NjA3OTAyIDAuOTAxOTYwNzkwMiAwLjkwMTk2MDc5MDIAA</bytes>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics">
<int key="IBUIStatusBarStyle">2</int>
Expand All @@ -87,11 +112,27 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">imageView</string>
<string key="label">imageView1</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="1049761250"/>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">imageView2</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="540458593"/>
</object>
<int key="connectionID">6</int>
<int key="connectionID">10</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">imageView3</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="218419576"/>
</object>
<int key="connectionID">11</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
Expand All @@ -109,6 +150,8 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="540458593"/>
<reference ref="1049761250"/>
<reference ref="218419576"/>
</object>
<reference key="parent" ref="0"/>
</object>
Expand All @@ -128,6 +171,16 @@
<reference key="object" ref="540458593"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="1049761250"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="218419576"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -139,6 +192,8 @@
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -147,6 +202,8 @@
<string>{{514, 109}, {768, 1024}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
Expand All @@ -161,7 +218,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">6</int>
<int key="maxID">11</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -170,14 +227,42 @@
<string key="className">RootViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">imageView</string>
<string key="NS.object.0">UIImageView</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>imageView1</string>
<string>imageView2</string>
<string>imageView3</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIImageView</string>
<string>UIImageView</string>
<string>UIImageView</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">imageView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">imageView</string>
<string key="candidateClassName">UIImageView</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>imageView1</string>
<string>imageView2</string>
<string>imageView3</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">imageView1</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">imageView2</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">imageView3</string>
<string key="candidateClassName">UIImageView</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
Expand All @@ -196,8 +281,19 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">astroland.jpg</string>
<string key="NS.object.0">{640, 480}</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>astroland.jpg</string>
<string>subway.jpg</string>
<string>tower.jpg</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{640, 480}</string>
<string>{640, 480}</string>
<string>{640, 480}</string>
</object>
</object>
<string key="IBCocoaTouchPluginVersion">300</string>
</data>
Expand Down
Loading

0 comments on commit fc208af

Please sign in to comment.