UITabBarController - 检测选项卡何时被取消选择
如果您有 4 个选项卡,那么通知视图控制器之一它已被“取消选择”的最佳方式是什么。换句话说,选择了另一个选项卡?
我不能只使用 viewDidDisappear,因为无论如何这都可能发生。视图控制器是否有另一种方法知道它不再是活动选项卡?
TabBar 委托(didSelectViewController)告诉我选择了哪个选项卡,但我需要知道在选择之前哪个选项卡处于活动状态,以便我可以告诉视图控制器杀死一些东西。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
shouldSelectViewController 有一个 TabBar 委托方法,该方法被调用以请求更改视图控制器的权限,以及 selectedViewController 或 selectedIndex 的 UITabBarController 属性。
需要验证 selectedIndex 或 selectedViewController 在 shouldSelectViewController 方法返回之前不会更改...
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...