在 TouchesEnded 上,我想做两件事:1)将视图返回到其原始位置 - 这工作正常。2) 如果触摸在 YES 视图上结束,我想播放音频声音,而在 NO 视图上播放不同的声音。
我怎样才能做到这一点?
此时,我的“NO”声音将在每次触摸结束时播放 - 这并不好。
我是新手,所以请解释一下基础知识:) 我当前的代码如下。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
yesletter1.frame = keepYesLetter1Place;
yesletter2.frame = keepYesLetter2Place;
yesletter3.frame = keepYesLetter3Place;
yesletter4.frame = keepYesLetter4Place;
notletter1.frame = keepNoLetter1Place;
notletter2.frame = keepNoLetter2Place;
notletter3.frame = keepNoLetter3Place;
notletter4.frame = keepNoLetter4Place;
NSString *path = [[NSBundle mainBundle]
pathForResource:@"no"ofType:@"wav"];
AVAudioPlayer* theAudio = [[AVAudioPlayer alloc]
initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio play];
}