开发者

touchesBegan question in iphone sdk?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜