-1

I am developing Camera App. I want to detect the number of taps that user has tapped. How can I get number of taps from the user.

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapResponder:)];
tap.numberOfTapsRequired =1;
[self.view addGestureRecognizer:tap];

-(void)tapResponder: (UITapGestureRecognizer *)sender{
   NSLog(@"Double Tapped");
}

Also, I want to limit user to tap only 50 taps. Here i can able to fit the taps instead of 1 but, how to detect how many taps that the user has tapped and stop the camera. Please help me to do this. I don't have much knowledge about the tap gesture.

byJeevan
  • 3,728
  • 3
  • 37
  • 60
Chandrika Visvesh
  • 91
  • 1
  • 1
  • 10

2 Answers2

0

Create global class variable like "userTaps" and iterate it each time if method tapResponder was called, so it means each time when user perform tap action.

Mr. A
  • 704
  • 1
  • 7
  • 16
0

To limit the number of taps, in your case 50 Taps,

tap.numberOfTapsRequired = 50;

In case if you are limiting the user for 50 taps, then there is no point to count the taps. The selector tapResponder: will get called only after exact 50 taps.

byJeevan
  • 3,728
  • 3
  • 37
  • 60