iOS - 在导航更改时停止视频

发布于 2024-10-20 08:07:51 字数 118 浏览 1 评论 0原文

所以这是我的困境,我有一个控制三个视图的导航控制器。第一个视图上有音频,第二个视图图像序列/视频,第三个视图将有音频。

当有人单击“后退”按钮转到编号较低的视图时,如何确保所有这些事情都结束(或只是结束)?

So here is my dilemma, I have a navigation controller that controls three views. The first view has audio on it, the second view image sequences/videos and the third view will have audio.

How can I make sure that all of those things are ended (or just end them) when someone clicks the "Back" button to go to a lower numbered view?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傲娇萝莉攻 2024-10-27 08:07:51

媒体播放器类(例如音频和视频)通常具有可以实现这一目的的“停止”方法。您可以挂钩 UIViewController 上的 viewWill/Did/Appear/Disapper 方法来了解视图何时/确实变得可见/不可见,并在那时停止媒体播放。我还喜欢在 viewWillUnload 和 dealloc 中对媒体播放器进行 put“stop”方法调用。

media player classes, like audio and video, usually have "stop" methods that will do the trick. You can hook in to the viewWill/Did/Appear/Disapper methods on UIViewController to know when a view is/did become(ing) visible/invisible and stop the media playback at that time. I also like to put put "stop" method calls to media players in viewWillUnload and dealloc.

半衾梦 2024-10-27 08:07:51

让自己成为 UINavigationController 的委托并实现它:

- (void)navigationController:(UINavigationController *)navController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // Pseudo Code Here
    [audio stopPlaying];
}

Make yourself the delegate of the UINavigationController and implement this:

- (void)navigationController:(UINavigationController *)navController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    // Pseudo Code Here
    [audio stopPlaying];
}
画离情绘悲伤 2024-10-27 08:07:51

看看 UINavigationControllerDelegate。它需要方法。

Look at UINavigationControllerDelegate. It has needed methods.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文