sol
sol

Reputation: 6462

UITabBarController - detect when tab is UNselected

If you have 4 tabs, what is the best way to inform one of the view controllers that it has been "deselected". In other words, that another tab was selected?

I can't just use viewDidDisappear, because that may happen anyway. Is there another way for a view controller to know that it is no longer the active tab?

The TabBar delegate (didSelectViewController) tells me which was selected, but I need to know which tab was active BEFORE the selection, so that I can tell the view controller to kill some things.

Upvotes: 1

Views: 610

Answers (1)

joebonniwell
joebonniwell

Reputation: 574

There is a TabBar delegate method of shouldSelectViewController which gets called to ask permission to change the view controller and a UITabBarController property of selectedViewController or selectedIndex.

Would need to verify that selectedIndex or selectedViewController does not change until the shouldSelectViewController method returns though...

Upvotes: 2

Related Questions