ユーザーがオブジェクトを移動させると、移動が終了するとディスプレイが更新され、サウンドが再生されます。それはすべてうまくいきますが、ビューが最初にロードされたときにサウンドが再生されることは望ましくありません。これをどうしたらいいのでしょうか? viewDidLoadに何かを配置する必要がありますか?イベントを発生させるコードは次のとおりです。助けてくれてありがとう。 `ビューの読み込み時にサウンドが再生されないようにしたい
// Updates the text field with the current rotation angle and play sound.
- (void) updateTextDisplay
{
NSError *error = nil;
if (imageAngle >=0 && imageAngle <=180){
ComplimentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"nice" ofType:@"m4a"]] error:&error];
ComplimentPlayer.delegate = self;
textDisplay.text = [NSString stringWithFormat:@"blah blah blah"];
} else if (imageAngle >180 && imageAngle <=360){
ComplimentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"good" ofType:@"m4a"]] error:&error];
ComplimentPlayer.delegate = self;
textDisplay.text = [NSString stringWithFormat:@"blah blah"];
}
NSTimeInterval playbackDelay = 0.5;
[ComplimentPlayer playAtTime: ComplimentPlayer.deviceCurrentTime + playbackDelay];
} `
ありがとう私はそのショットを与えるでしょう。 – mmoore410