开发者

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

开发者 https://www.devze.com 2023-01-19 18:06 出处:网络
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 viewwilldisap

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, Niki开发者_开发知识库l


This worked for me.

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

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号