views:

301

answers:

1

How do I code this so that that it detects which image was tapped first? In other words if one of them is tapped, but the other one was already hidden, i want it to play a different sound?? any ideas?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *touch = [touches anyObject]; 
    NSLog(@"tag %@",touch); 
    if([touch view] == test) { 
        test.hidden=YES;
        [self playpopsound];
    }
    else if([touch view] == test2){
        test2.hidden=YES;
        [self playpopsound];
    }
}
+2  A: 

Each UIView can have a unique tag associated with it, which is just an unsigned integer. You can compare tags of views to quickly test their equivalence.

Alex Reynolds