[英]How to pause the audio once after going back to another view controller IOS7
Hi I'm playing the audio file in one view controller when i going the another view controller its still playing the audio how to pause the audio when we going back to another view controller. 嗨,当我转到另一个视图控制器时,我正在一个视图控制器中播放音频文件,当我们返回另一个视图控制器时,它仍在播放音频,如何暂停音频。
- (void)dealloc {
if ([self.audioPlayer isPlaying])
[self.audioPlayer stop];
[super dealloc];
}
The above code is only works on the navigation view controller if navigate form using the navigation view controller. 如果使用导航视图控制器导航表单,则以上代码仅在导航视图控制器上有效。 But i use the normal view controller if i click the back button the audio still plays the audio. 但是,如果我单击“后退”按钮,音频仍会播放音频,那么我将使用普通的视图控制器。 This above code is not working on the normal view controller. 上面的代码不适用于普通视图控制器。 Please tell how to pause the audio on the normal view controller. 请告诉您如何在普通视图控制器上暂停音频。
Thanks. 谢谢。
Add your code in ViewWillDisappear
在ViewWillDisappear
添加代码
- (void)viewWillDisappear{
if ([self.audioPlayer isPlaying])
[self.audioPlayer stop];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.