当同时点击2个按钮时,UITabBar禁用

时间:2014-04-14 16:02:50

标签: ios uiview uiviewcontroller transition uitabbar

我目前有以下"控制器树":

  

的UITabBarController
  ┣━UIViewController( A
  ┃┃MKMapView
  ┣━UINavigationController
  ┃┃━UITableViewController( X
  ┃┃━UITableViewController( B
  ┣━UIViewController(不感兴趣)
  ┗━UIViewController(不感兴趣)

在第二个视图(B)中,我有一个连接到IBAction的按钮:

- (IBAction)mapButtonTapped:(UIBarButtonItem *)sender {
        UIView *startView = self.tabBarController.selectedViewController.view;
        UIView *endView = ((UIViewController *)[self.tabBarController.viewControllers objectAtIndex:ELMapViewControllerIndex]).view;
        ElMainMapViewController *carparkVC = [self.tabBarController.viewControllers objectAtIndex:ELMapViewControllerIndex];
        [UIView transitionFromView:startView toView:endView duration:ELAnimationDuration
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        completion:^(BOOL finished) {
                        }];
    }

代码取自: iPhone: How to switch tabs with an animation?

一切正常完美 - 当按钮我点击按钮时,我的第二个标签视图稍微改变为第一个,一切都按照我想要的方式工作。

不幸的是,我的QA同时点击后退按钮和按钮连接到上面的功能。这有时会导致锁定UITabBar。我能够移动MKMapView和任何子视图,但UITabBar的行为与禁用的用户互动相似。

如果这"组合"没有锁定UITabBar它有时会导致"<" B 中的后退按钮附近的符号ViewController比它应该更薄。

我真的不知道如何解决这个问题。我检查了viewWillAppear和其他功能,但没有与UITabBar达成协议(我不会在UITabBar的任何其他功能中保留引用)。

修改

我删除了在tabBar中更改选定的索引,但仍会出现此问题。

1 个答案:

答案 0 :(得分:0)

您需要在启动动画之前禁用控件,然后在完成块中重新启用它们。

对于每个项目,请使用以下内容:

[[[[self.tabBarController tabBar] items] objectAtIndex:1] setEnabled:NO];
动画完成时

然后setEnabled:YES

相关问题