如何对其进行编码,以便它能够检测到首先点击了哪个图像?换句话说,如果其中一个被轻敲,但另一个已被隐藏,我想让它发出不同的声音?任何想法?
- (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];
}
}
答案 0 :(得分:3)
每个UIView
都可以有一个与之关联的唯一tag
,它只是一个无符号整数。您可以比较视图标记以快速测试它们的等效性。