TapTapsViewController.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:2k
源码类别:

iPhone

开发平台:

MultiPlatform

  1. //
  2. //  TapTapsAppDelegate.m
  3. //  TapTaps
  4. //
  5. //  Created by Jeff LaMarche on 8/3/08.
  6. //  Copyright __MyCompanyName__ 2008. All rights reserved.
  7. //
  8. #import "TapTapsViewController.h"
  9. @implementation TapTapsViewController
  10. @synthesize singleLabel;
  11. @synthesize doubleLabel;
  12. @synthesize tripleLabel;
  13. @synthesize quadrupleLabel;
  14. - (void)singleTap {
  15. singleLabel.text = @"Single Tap Detected";
  16. [self performSelector:@selector(eraseMe:) withObject:singleLabel afterDelay:1.6f];
  17. }
  18. - (void)doubleTap {
  19. doubleLabel.text = @"Double Tap Detected";
  20. [self performSelector:@selector(eraseMe:) withObject:doubleLabel afterDelay:1.6f];
  21. }
  22. - (void)tripleTap {
  23. tripleLabel.text = @"Triple Tap Detected";
  24. [self performSelector:@selector(eraseMe:) withObject:tripleLabel afterDelay:1.6f];
  25. }
  26. - (void)quadrupleTap {
  27. quadrupleLabel.text = @"Quadruple Tap Detected";
  28. [self performSelector:@selector(eraseMe:) withObject:quadrupleLabel afterDelay:1.6f];
  29. }
  30. - (void)eraseMe:(UITextField *)textField {
  31. textField.text = @"";
  32. }
  33. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  34. // Return YES for supported orientations
  35. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  36. }
  37. - (void)didReceiveMemoryWarning {
  38. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  39. // Release anything that's not essential, such as cached data
  40. }
  41. - (void)dealloc {
  42. [singleLabel release];
  43. [doubleLabel release];
  44. [tripleLabel release];
  45. [quadrupleLabel release];
  46. [super dealloc];
  47. }
  48. #pragma mark -
  49. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  50. UITouch *touch = [touches anyObject];
  51. NSUInteger tapCount = [touch tapCount];
  52. switch (tapCount) {
  53. case 1:
  54. [self performSelector:@selector(singleTap) withObject:nil afterDelay:.4];
  55. break;
  56. case 2:
  57. [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTap) object:nil];
  58. [self performSelector:@selector(doubleTap) withObject:nil afterDelay:.4];
  59. break;
  60. case 3:
  61. [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doubleTap) object:nil];
  62. [self performSelector:@selector(tripleTap) withObject:nil afterDelay:.4];
  63. break;
  64. case 4:
  65. [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tripleTap) object:nil];
  66. [self quadrupleTap];
  67. break;
  68. default:
  69. break;
  70. }
  71. }
  72. @end