开发者

touchesBegan question in iphone sdk?

开发者 https://www.devze.com 2022-12-20 11:18 出处:网络
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?

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([tou开发者_如何学Cch view] == test) { 
        test.hidden=YES;
        [self playpopsound];
    }
    else if([touch view] == test2){
        test2.hidden=YES;
        [self playpopsound];
    }
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消