【发布时间】:2011-04-23 14:55:37
【问题描述】:
如何在更改视图时停止背景音乐?我没有线索。如果我按下一个将我带到新视图的按钮,就会有新的背景音乐。但旧的背景音乐(无限循环)仍在继续。请帮忙!也请示例一些代码,这是我的:
- (void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"MathMusic2" ofType:@"wav"];
AVAudioPlayer* theAudio= [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
theAudio.numberOfLoops = -1;
[super viewDidLoad];
}
我只需要知道如何让新视图中的背景音乐停止播放。当我在新视图中按下后退按钮时,反之亦然
【问题讨论】:
标签: iphone objective-c xcode ios audio