【问题标题】:UITabBarController selected tab bug (?)UITabBarController 选择选项卡错误(?)
【发布时间】:2012-05-12 07:17:30
【问题描述】:

我的应用程序有一个带有 4 个选项卡的 UITabBarController,从父级显示为模态视图控制器。应用程序完全支持横向,因此可以随时进行布局。

有一个非常奇怪的错误,上个月我只看到了 5 次。不知何故,经过一些操作(用户无法说出确切的顺序,但它显然涉及方向更改)选定的选项卡项目保持“横向”,而其他选项卡项目则正确定位。 我无法提供更多信息,因为这是一个非常落后的错误。

编辑:它也发生在另一个人编写的另一个应用程序中,所以这实际上可能是一个 iOS 错误。

截图:

【问题讨论】:

    标签: ios uitabbarcontroller


    【解决方案1】:

    您可以尝试在UITabBarController 中的每个UIViewController 上实现- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation,然后在旋转后设置tabBarController 的@property(nonatomic) NSUInteger selectedIndex 属性?

    我之前没有尝试过,但它可以工作......像这样:

     - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
          [[self tabBarController] setSelectedIndex:[[self tabBarController] selectedIndex]];
     }
    

    【讨论】:

    • 我正在考虑在 viewWillAppear 中强制布局。但我希望有人已经面临这个问题,并且可能有解决方案或至少有一个解释。
    • 看到 UITabBar 继承 UIView 你也可以尝试调用 [[[self tabBarController] tabBar] layoutSubviews] On the rotate or viewWillAppear then 但是很奇怪,这种情况正在发生......你在自定义外观吗tabBar 无论如何还是继承它?
    • 不,我不是。问题似乎也出现在另一个人编写的另一个应用程序中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-24
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多