触摸iphone sdk中的问题?

时间:2010-02-18 23:51:22

标签: iphone image sdk touch detection

如何对其进行编码,以便它能够检测到首先点击了哪个图像?换句话说,如果其中一个被轻敲,但另一个已被隐藏,我想让它发出不同的声音?任何想法?

- (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];
    }
}

1 个答案:

答案 0 :(得分:3)

每个UIView都可以有一个与之关联的唯一tag,它只是一个无符号整数。您可以比较视图标记以快速测试它们的等效性。