简体   繁体   English

touches开始在iPhone SDK中出现问题吗?

[英]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([touch 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. 每个UIView都可以具有与其关联的唯一tag ,这只是一个无符号整数。 You can compare tags of views to quickly test their equivalence. 您可以比较视图标签以快速测试它们的等效性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM