0
我有兩個視圖控制器:停止AVAudioPlayer
MainMenuView:
- (void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"BackgroundSound" ofType:@"mp3"];
play =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
play.delegate=self;
[play play];
}
和PlayAreaView:
- (void)counttimer
{
///here is my code for NSTimer, if Timer is 0, Automatically I go to GameOver viewController
MainMenuView *vv = [[MainMenu alloc]init];
[vv.play stop];
GameOver *gv = [[GameOver alloc]init];
[self presentViewController:gv animated:YES completion:nil];
}
我去GAMEOVER之前,或者當我已經在遊戲結束圖,我想停止AVAudioPlayer
從我的MainMenuView
。請幫助。我試圖分配MainMenuView
,並使用[MainMenu.play stop]
,但不起作用。
PlayAreaView是在MainMenuView之前還是在它的對面? –