开发者

UITabBarController - detect when tab is UNselected

开发者 https://www.devze.com 2023-01-22 03:56 出处:网络
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?

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 BE开发者_开发技巧FORE the selection, so that I can tell the view controller to kill some things.


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消