Nikil
Nikil

Reputation: 11

How to Unload a TabBar View when New TabBar view is loaded?

I am playing an audio file in a viewcontroller inside an UITabBar using AVAudioPlayer. So when user clicks a different tabbar item the music is not stopped. I tried adding stop method in viewwilldisappear. But it's not responding. How can I stop my audio when user clicks a new tab bar item. ente

AVAudioPlayer *audioPlayer;

This is my code in view will disappear

[audioPlayer stop];
[sliderTimer invalidate];
audioPlayer = nil;
self.URL = nil;
self.musicTitle = nil;

Thanks, Nikil

Upvotes: 1

Views: 381

Answers (1)

Ram
Ram

Reputation: 11

This worked for me.

  • (void)viewWillDisappear:(BOOL)animated { [self.audioPlayer stop];

}

Upvotes: 1

Related Questions