Permalink
Browse files

Updated/modernized code to have style parity with my other code, and …

…made some other minor changes.
  • Loading branch information...
1 parent 31ebba4 commit 4c4424ab7a692417058891aaf21499ad233391cb @neror committed Mar 7, 2011
@@ -23,9 +23,8 @@ of this software and associated documentation files (the "Software"), to deal
*/
#import "ContinuousGestures.h"
-#import <QuartzCore/QuartzCore.h>
-@interface ContinuousGestures (GestureRecognition)
+@interface ContinuousGestures()
- (void)addGestureRecognizersToView:(UIView *)theView;
- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)recognizer;
@@ -40,10 +39,10 @@ - (void)handleTwoFingerTap:(UITapGestureRecognizer *)recognizer;
@implementation ContinuousGestures
-@synthesize redView;
-@synthesize greenView;
-@synthesize blueView;
-@synthesize orangeView;
+@synthesize redView = redView_;
+@synthesize greenView = greenView_;
+@synthesize blueView = blueView_;
+@synthesize orangeView = orangeView_;
+ (NSString *)friendlyName {
return @"Continuous Gestures";
@@ -70,10 +69,10 @@ - (void)viewDidLoad {
}
- (void)dealloc {
- [redView release];
- [greenView release];
- [blueView release];
- [orangeView release];
+ [redView_ release], redView_ = nil;
+ [greenView_ release], greenView_ = nil;
+ [blueView_ release], blueView_ = nil;
+ [orangeView_ release], orangeView_ = nil;
[super dealloc];
}
@@ -26,7 +26,7 @@
#import "ExampleController.h"
@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate> {
- UIPopoverController *popoverController;
+
}
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
@@ -25,20 +25,23 @@ of this software and associated documentation files (the "Software"), to deal
#import "DetailViewController.h"
#import "RootViewController.h"
-@interface DetailViewController ()
+@interface DetailViewController() {
+}
@property (nonatomic, retain) UIPopoverController *popoverController;
+
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer;
- (void)resetCurrentExample;
+
@end
@implementation DetailViewController
-@synthesize toolbar;
-@synthesize popoverController;
-@synthesize exampleController;
-@synthesize contentView;
-@synthesize titleLabel;
+@synthesize toolbar = toolbar_;
+@synthesize popoverController = popoverController_;
+@synthesize exampleController = exampleController_;
+@synthesize contentView = contentView_;
+@synthesize titleLabel = titleLabel_;
- (void)viewDidLoad {
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
@@ -51,11 +54,11 @@ - (void)viewDidUnload {
}
- (void)dealloc {
- [popoverController release];
- [toolbar release];
- [exampleController release];
- [contentView release];
- [titleLabel release];
+ [popoverController_ release], popoverController_ = nil;
+ [toolbar_ release], toolbar_ = nil;
+ [exampleController_ release], exampleController_ = nil;
+ [contentView_ release], contentView_ = nil;
+ [titleLabel_ release], titleLabel_ = nil;
[super dealloc];
}
@@ -84,20 +87,27 @@ - (void)resetCurrentExample {
#pragma mark Managing the detail item
- (void)setExampleController:(ExampleController *)newExample {
- if (exampleController != newExample) {
- [exampleController viewWillDisappear:YES];
+ if(exampleController_ != newExample) {
+ [exampleController_ viewWillDisappear:YES];
[newExample viewWillAppear:YES];
- [exampleController.view removeFromSuperview];
- [self.contentView insertSubview:newExample.view belowSubview:self.toolbar];
- [exampleController viewDidDisappear:YES];
- [newExample viewDidAppear:YES];
-
- [self.titleLabel setText:[[newExample class] friendlyName]];
+
+ ExampleController *currentController = exampleController_;
- [exampleController release];
- exampleController = [newExample retain];
+ newExample.view.alpha = 0.f;
+ [UIView animateWithDuration:.25f animations:^{
+ [self.contentView insertSubview:newExample.view belowSubview:self.toolbar];
+ [self.titleLabel setText:[[newExample class] friendlyName]];
+ newExample.view.alpha = 1.f;
+ currentController.view.alpha = 0.f;
+ } completion:^(BOOL finished) {
+ [currentController.view removeFromSuperview];
+ [currentController viewDidDisappear:YES];
+ [newExample viewDidAppear:YES];
+ }];
+
+ [exampleController_ release];
+ exampleController_ = [newExample retain];
}
-
if (self.popoverController != nil) {
[self.popoverController dismissPopoverAnimated:YES];
}
@@ -113,9 +123,9 @@ - (void)splitViewController:(UISplitViewController*)svc
{
barButtonItem.title = @"Gesture Examples";
- NSMutableArray *items = [[toolbar items] mutableCopy];
+ NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items insertObject:barButtonItem atIndex:0];
- [toolbar setItems:items animated:YES];
+ [self.toolbar setItems:items animated:YES];
[items release];
self.popoverController = pc;
}
@@ -124,9 +134,9 @@ - (void)splitViewController: (UISplitViewController*)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
- NSMutableArray *items = [[toolbar items] mutableCopy];
+ NSMutableArray *items = [[self.toolbar items] mutableCopy];
[items removeObjectAtIndex:0];
- [toolbar setItems:items animated:YES];
+ [self.toolbar setItems:items animated:YES];
[items release];
self.popoverController = nil;
}
@@ -23,14 +23,11 @@
*/
#import <UIKit/UIKit.h>
-#import <QuartzCore/QuartzCore.h>
#import "ExampleController.h"
@interface DiscreteGestures : ExampleController {
- CAShapeLayer *eventIndicator_;
}
@property (nonatomic,retain) IBOutlet UILabel *eventTypeLabel;
-@property (readonly) CALayer *eventIndicator;
@end
@@ -24,7 +24,11 @@ of this software and associated documentation files (the "Software"), to deal
#import "DiscreteGestures.h"
-@interface DiscreteGestures (GestureHandlers)
+@interface DiscreteGestures() {
+ CAShapeLayer *eventIndicator_;
+}
+
+@property (readonly) CALayer *eventIndicator;
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer;
- (void)handleTwoFingerDoubleTap:(UITapGestureRecognizer *)recognizer;
@@ -35,15 +39,15 @@ - (void)handleThreeFingerSwipe:(UISwipeGestureRecognizer *)recognizer;
@implementation DiscreteGestures
-@synthesize eventTypeLabel;
+@synthesize eventTypeLabel = eventTypeLabel_;
+ (NSString *)friendlyName {
return @"Discrete Gestures";
}
- (void)dealloc {
- [eventIndicator_ release];
- [eventTypeLabel release];
+ [eventIndicator_ release], eventIndicator_ = nil;
+ [eventTypeLabel_ release], eventTypeLabel_ = nil;
[super dealloc];
}
@@ -2,17 +2,16 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1056</int>
- <string key="IBDocument.SystemVersion">10F569</string>
- <string key="IBDocument.InterfaceBuilderVersion">823</string>
- <string key="IBDocument.AppKitVersion">1038.29</string>
- <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <string key="IBDocument.SystemVersion">10J567</string>
+ <string key="IBDocument.InterfaceBuilderVersion">844</string>
+ <string key="IBDocument.AppKitVersion">1038.35</string>
+ <string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">132</string>
+ <string key="NS.object.0">141</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -38,7 +37,7 @@
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
</object>
<object class="IBUIView" id="766721923">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -72,7 +71,6 @@
</object>
</object>
<string key="NSFrameSize">{768, 1004}</string>
- <reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
@@ -109,11 +107,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">eventTypeLabel</string>
+ <string key="label">eventTypeLabel_</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="92245396"/>
</object>
- <int key="connectionID">13</int>
+ <int key="connectionID">14</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
@@ -193,7 +191,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">13</int>
+ <int key="maxID">14</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -202,13 +200,13 @@
<string key="className">DiscreteGestures</string>
<string key="superclassName">ExampleController</string>
<object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">eventTypeLabel</string>
+ <string key="NS.key.0">eventTypeLabel_</string>
<string key="NS.object.0">UILabel</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
- <string key="NS.key.0">eventTypeLabel</string>
+ <string key="NS.key.0">eventTypeLabel_</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
- <string key="name">eventTypeLabel</string>
+ <string key="name">eventTypeLabel_</string>
<string key="candidateClassName">UILabel</string>
</object>
</object>
@@ -443,6 +441,6 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../UIGestureExamples.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">132</string>
+ <string key="IBCocoaTouchPluginVersion">141</string>
</data>
</archive>
@@ -28,8 +28,6 @@
@interface GestureInteraction : ExampleController <UIGestureRecognizerDelegate> {
- NSDictionary *stateColorMap_;
- CAShapeLayer *centroidLayer_;
}
@property (nonatomic, retain) IBOutlet UIView *containerView;
Oops, something went wrong.

0 comments on commit 4c4424a

Please sign in to comment.