简体   繁体   English

回到另一个视图控制器IOS7后如何暂停一次音频

[英]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.

相关问题 如何只显示一次IOS7的视图控制器 - how to display view controller only once IOS7 如何从PhotoLibrary IOS7返回主视图控制器 - How to go Back to Main View Controller form PhotoLibrary IOS7 从该音频回来后如何停止音频ViewController IOS7 - How to Stop the Audio After Coming Back From that audio ViewController IOS7 从另一个视图控制器返回后,如何在主故事板上保留大标题? - How to keep large title on for main storyboard after going back from another view controller? 从iOS中的另一个视图控制器向后导航后,如何将SearchBar设置为活动状态 - How to set SearchBar to be active after navigating back from another view controller in iOS ios7-在另一个视图上显示视图控制器,但不全屏显示 - ios7 - showing a view controller on top of another but not in full screen 将数据从didSelectRowAtIndexPath传递到另一个视图控制器ios7 - passing data from didSelectRowAtIndexPath to another view controller ios7 选择Image IOS7后自动返回上传View Controller - Automatically Return to Upload View Controller after Selecting the Image IOS7 在iOS上关闭View Controller后,如何继续播放音频? - How to continue to play audio after view controller is dismissed on iOS? iOS-返回时如何推送至视图控制器并维护正确的“ View Stack” - iOS - How to push to a view controller and maintain the correct “View Stack” when going back
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM