iPhone XCode编程:在选项卡栏应用程序中更改选项卡时执行代码
我正在为学校开发一个简单的标签栏应用程序。 它有 3 个选项卡。 其中之一在流媒体中播放音乐,我想在用户更改选项卡时停止音乐播放。这可能吗?以及如何?先感谢您!
I'm developing a simple tab bar application for school.
It has 3 tabs.
One of them plays music in streaming and I would like to stop the music playing when the user changes the tab. Is this possible? and How? Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实现
UITabViewController
委托方法:您应该能够做您想做的事情。还有
如果您想在选项卡更改之前了解情况。
Implement the
UITabViewController
delegate method:And you should be able to do what you want. There's also
if you want to know before the tab changes.
正如卡尔所说,这是可能的。但是,如果我要开发这样的应用程序(实际上,我就是这样),我会使用我的
UIViewController
的viewWillDisappear
方法(而且我就是这样)。这样您就可以在实现之间保持逻辑分离。As Carl says, this is possible. However, if I were to develop such application (and actually, I am), I would use the
viewWillDisappear
method of myUIViewController
(and I am). That way you keep the logic separated between your implementations.