views:

372

answers:

2

Hello! 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!

+3  A: 

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.

Carl Norum
Do you mean `UITabBarController`?
Andrew
+2  A: 

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.

Björn
+1, also a good solution to the problem.
Carl Norum