我有一个用户移动一个对象,当移动结束时它将更新显示并播放声音。这一切都很好,但我不希望播放视图时播放声音。我如何避免这种情况发生?我需要在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 2012-02-29 23:37:49