简体   繁体   English

UITabBarController选择的选项卡错误(?)

[英]UITabBarController selected tab bug (?)

My application has an UITabBarController with 4 tabs, presented as modal view controller from parent. 我的应用程序有一个带有4个选项卡的UITabBarController,从父级显示为模式视图控制器。 Application has full support for landscape orientation, so layouts may occur at any time. 应用程序完全支持横向方向,因此可以随时进行布局。

There is a very strange bug that I've seen only 5 times for the last month. 有一个非常奇怪的错误,上个月我只见过5次。 Somehow after some operations (users can't tell the exact order, but it obviously involves orientation changes) selected tab item stays "landscape" while others get positioned properly. 在执行某些操作(用户不能说出确切顺序,但显然涉及方向更改)后,选定的选项卡项目将保持“横向”状态,而其他选项卡则处于正确的位置。 I can't provide more information because it's a very rear bug. 我无法提供更多信息,因为它是一个非常严重的错误。

Edit: it also happens in another application written by another person, so this might be actually an iOS bug. 编辑:它也发生在另一个人编写的另一个应用程序中,因此这实际上可能是一个iOS错误。

Screenshot: 屏幕截图: 在此处输入图片说明

You could try implementing the - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation on each UIViewController in your UITabBarController and then set the @property(nonatomic) NSUInteger selectedIndex property of the tabBarController after the rotate? 您可以尝试在UITabBarController每个UIViewController上实现- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation ,然后在旋转后设置- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation @property(nonatomic) NSUInteger selectedIndex属性。

I haven't tried it before but it could work... Something like this: 我以前没有尝试过,但是可以正常工作……

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM