【问题标题】:UITabBar disables when simulraneously click 2 buttonsUITabBar 在同时单击 2 个按钮时禁用
【发布时间】:2014-04-14 16:02:49
【问题描述】:

我目前有以下“控制器树”:

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 中删除了更改选定的索引,但仍然出现此问题。

【问题讨论】:

    标签: ios uiview uiviewcontroller transition uitabbar


    【解决方案1】:

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

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

    [[[[self.tabBarController tabBar] items] objectAtIndex:1] setEnabled:NO];
    

    然后在动画完成时setEnabled:YES

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-07
      • 2023-03-28
      • 2022-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多