I want my application to display a different alert the on the 1st touch, the 3rd touch, and the 5th touch, but every time I tap the screen after hitting OK on the alert for the first touch, it displays the alert for the 1st touch again.
Code:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* touch = [touches anyObject];
NSUInteger numTaps = [touch tapCount];
if (numTaps == 1 ) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tap #1" message:@"You have tapped once" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release]; }
if (numTaps == 3) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tap #3" message:@"You have tapped three times. " delegate:self cancelButtonTitle:@"OK otherButtonTitles:nil];
[alert show];
[alert release]; }
if (numTaps == 5) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tap #5" message:@"You have tapped five times " delegate:self cancelButtonTitle:@"OK." otherButtonTitles:nil];
[alert show];
[alert release];
}
}