Created
December 19, 2011 07:10
-
-
Save linktoming/1495829 to your computer and use it in GitHub Desktop.
UIResponder's Touch Handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - | |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
messageLabel.text = @"Touches Began"; | |
[self updateLabelsFromTouches:touches]; | |
} | |
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
messageLabel.text = @"Drag Detected"; | |
[self updateLabelsFromTouches:touches]; | |
} | |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { | |
messageLabel.text = @"Touches Ended."; | |
[self updateLabelsFromTouches:touches]; | |
} | |
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ | |
messageLabel.text = @"Touches Cancelled"; | |
[self updateLabelsFromTouches:touches]; | |
} | |
- (void)updateLabelsFromTouches:(NSSet *)touches { | |
NSUInteger numTaps = [[touches anyObject] tapCount]; | |
NSString *tapsMessage = [[NSString alloc] initWithFormat:@"%d taps detected", numTaps]; | |
tapsLabel.text = tapsMessage; | |
[tapsMessage release]; | |
NSUInteger numTouches = [touches count]; | |
NSString *touchMsg = [[NSString alloc] initWithFormat: @"%d touches detected", numTouches]; | |
touchesLabel.text = touchMsg; | |
[touchMsg release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment