iPhone XCode programming: execute code when change tab in a tab bar application
I'm developing a simple tab bar application for school. It has 3 tabs. One of them plays mus开发者_开发知识库ic 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!
Implement the UITabViewController
delegate method:
– tabBarController:didSelectViewController:
And you should be able to do what you want. There's also
– tabBarController:shouldSelectViewController:
if you want to know before the tab changes.
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 my UIViewController
(and I am). That way you keep the logic separated between your implementations.
精彩评论