Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created April 28, 2015 21:19
Show Gist options
  • Save C4Code/b4c962c482d7c0361316 to your computer and use it in GitHub Desktop.
Save C4Code/b4c962c482d7c0361316 to your computer and use it in GitHub Desktop.
New Gestures
//
// FirstWorkSpace.m
// tabbed
//
// Created by moi on 12-10-15.
// Copyright (c) 2012 moi. All rights reserved.
//
#import "FirstWorkSpace.h"
@implementation FirstWorkSpace
-(void)setup {
self.canvas.backgroundColor = C4BLUE;
self.title = @"First";
//to register a gesture, pass it a block
[self.canvas onSwipeUp:^(CGPoint location) {
//in this block I simply call a method I created and pass the location to it
[self up:location];
}];
[self.canvas onSwipeDown:^(CGPoint location) {
[self down:location];
}];
//to kill a gesture pass nil to it's "on" method
//I'm killing the default Pan gesture so that it doesn't collide with the swipe gestures
[self.canvas onPan:nil];
}
#pragma mark - built-in methods
//There are two tapped methods, this one doesn't take a location
//-(void)tapped {
//
//}
-(void)tapped:(CGPoint)location {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
//There are two longPressStarted methods, this one doesn't take a location
//-(void)longPressStarted {
//
//}
-(void)longPressStarted:(CGPoint)location {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
//There are two longPressStarted methods, this one doesn't take a location
//-(void)longPressStarted {
//
//}
-(void)longPressEnded:(CGPoint)location {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
//There are two panned methods, this one doesn't take any variables
//-(void)panned {
//
//}
-(void)panned:(CGPoint)location translation:(CGPoint)translation velocity:(CGPoint)velocity {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
#pragma mark - custom methods
-(void)up:(CGPoint)location {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
-(void)down:(CGPoint)location {
C4Log(@"%@ > %4.2f,%4.2f",NSStringFromSelector(_cmd),location.x,location.y);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment