在某些情况下,iOS 7 上的标签栏背景缺失。查看屏幕截图:
我对 UITabBarController 进行了子类化,并像这样模态地展示了我的子类:
[self.navigationController presentViewController:tabBarController animated:NO completion:nil];
有时,虽然这种情况很少见,但背景并没有出现在我的标签栏上,我可以直接看到它。没有半透明 View - 只有透明度......
我已经使用出色的 Reveal app 进行了调试并发现当我观察问题时,_UITabBarBackgroundView 在运行时从 UITabBar 中丢失(它应该是 UITabBar 的 subview )。值得注意的是,当背景缺失时,UIImageView 也会从 UITabBar 中缺失。
我很迷茫。什么可能导致标签栏丢失其 _UITabBarBackgroundView subview ?
最佳答案
根据文档,除了窗口的 Root View Controller 之外,你永远不应该将标签栏 Controller 用于任何东西:
When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.
假设像您所做的那样以模态方式呈现它在某些情况下会产生一些意想不到的副作用,这并非不合理。使用标签栏作为应用程序的根 Controller 时,您是否遇到过这个问题?
如您的屏幕截图所示,我有“不可见”的标签栏,但只有当我在设置背景图像时尝试变得聪明,但您说过您的代码不会发生这种情况。
关于ios - 为什么我的标签栏上缺少背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20226227/