私は2つのView Controllerを持っています:
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]
たが、うまくいきません。