gpt4 book ai didi

xcode - 触摸音频结束

转载 作者:行者123 更新时间:2023-12-03 02:24:04 25 4
gpt4 key购买 nike

在TouchesEnded上,我想做两件事:
1)将 View 返回其原始位置-可以正常工作。
2)如果触摸"is"结束而我想播放音频声音,而“否” View 出现其他声音。

我怎样才能做到这一点?

此时,我的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];
}

最佳答案

解决了这个问题,不是我想要的,而是现在可以正常工作。
对于某些物体,我有2种不同的声音,一种声音,另一种声音。
我所做的是为每个对象添加了一个标志,并且if(flag1 == 0 || flag2 == 0 ect ...)播放声音1否则播放声音2。
在另一种方法中,我做了一些标志。

我敢肯定有一个更好的解决方案:)但现在一切正常。

关于xcode - 触摸音频结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7695683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com