<i id='ixaro'><tr id='ixaro'><dt id='ixaro'><q id='ixaro'><span id='ixaro'><b id='ixaro'><form id='ixaro'><ins id='ixaro'></ins><ul id='ixaro'></ul><sub id='ixaro'></sub></form><legend id='ixaro'></legend><bdo id='ixaro'><pre id='ixaro'><center id='ixaro'></center></pre></bdo></b><th id='ixaro'></th></span></q></dt></tr></i><div id='ixaro'><tfoot id='ixaro'></tfoot><dl id='ixaro'><fieldset id='ixaro'></fieldset></dl></div>
      <bdo id='ixaro'></bdo><ul id='ixaro'></ul>

  • <tfoot id='ixaro'></tfoot>

    1. <legend id='ixaro'><style id='ixaro'><dir id='ixaro'><q id='ixaro'></q></dir></style></legend>

      1. <small id='ixaro'></small><noframes id='ixaro'>

        如何停止弹出到导航控制器的标签栏的第二次点击?

        时间:2023-06-12

          <tbody id='Xdrna'></tbody>
        • <small id='Xdrna'></small><noframes id='Xdrna'>

                <legend id='Xdrna'><style id='Xdrna'><dir id='Xdrna'><q id='Xdrna'></q></dir></style></legend>
                <tfoot id='Xdrna'></tfoot>
                <i id='Xdrna'><tr id='Xdrna'><dt id='Xdrna'><q id='Xdrna'><span id='Xdrna'><b id='Xdrna'><form id='Xdrna'><ins id='Xdrna'></ins><ul id='Xdrna'></ul><sub id='Xdrna'></sub></form><legend id='Xdrna'></legend><bdo id='Xdrna'><pre id='Xdrna'><center id='Xdrna'></center></pre></bdo></b><th id='Xdrna'></th></span></q></dt></tr></i><div id='Xdrna'><tfoot id='Xdrna'></tfoot><dl id='Xdrna'><fieldset id='Xdrna'></fieldset></dl></div>
                • <bdo id='Xdrna'></bdo><ul id='Xdrna'></ul>

                  本文介绍了如何停止弹出到导航控制器的标签栏的第二次点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个基于标签栏的应用程序.所有选项卡都有一个导航控制器作为根.如果标签处于活动状态,用户再次点击标签,它会弹回导航控制器.

                  I have a tab bar based app. All tabs have a navigation controller as the root. If the user taps on the tab again if the tab is active, it pops back to the navigation controller.

                  我怎样才能阻止这种行为?

                  How can I stop this behavior?

                  所以实际上我有一个导航控制器 + 一个隐藏的 viewcontroller 可以做出一些决定 + 另一个视图控制器.对于原始问题中的误导性信息,我们深表歉意.我对所有选项卡(其中 3 个)使用隐藏的 viewcontroller,并将 1,2,3 单独的 viewcontrollers 放在每个选项卡上.

                  So in fact I have a navigation controller + a hidden viewcontroller that makes some decisions + another view controller. Sorry for the misleading information in the original question. I use the hidden viewcontroller for all the tabs, 3 of them, since I have the login screen on all 3 if the user is not logged in. If the user logs in, then I pop the login screen, and put the 1,2,3 individual viewcontrollers on each tab.

                  第一次点击:

                   0 : class=Crossing: 0x645c8a0>  
                   1 : class=FavoritesViewController: 0x64ac140>  
                   shouldSelectViewController : UINavigationController  
                   UINavigationController topclass:FavoritesViewController  
                   myTabBarController.selectedViewController :UINavigationController  
                   did disappear  
                   didSelectViewController : UINavigationController  
                   UINavigationController topclass:FavoritesViewController  
                  

                  第二次点击:

                   0 : class=Crossing: 0x645c8a0>  
                   1 : class=FavoritesViewController: 0x64ac140>  
                   shouldSelectViewController : UINavigationController  
                   UINavigationController topclass:FavoritesViewController  
                   myTabBarController.selectedViewController :UINavigationController  
                   didSelectViewController : UINavigationController  
                   UINavigationController topclass:Crossing  
                  

                  推荐答案

                  @MarkGranoff 的做法是正确的,但方法是这样做:

                  @MarkGranoff was on the right track for doing this, but the way to do it is by doing something like this:

                  - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
                  {
                      if ([tabBarController.viewControllers indexOfObject:viewController] == tabBarController.selectedIndex)
                      {
                          return NO;
                      }
                      else
                      {
                          return YES;
                      }
                  }
                  

                  或者用一种不那么冗长的方式:

                  or in a less verbose way:

                  - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
                  {
                      return (viewController != tabBarController.selectedViewController);
                  }
                  

                  如果您只想阻止某个选项卡的默认行为,那么您可以执行以下操作:

                  If you only want to block the default behaviour for a certain tab then you can do something like this:

                  - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
                  {
                      NSUInteger indexOfNewViewController = [tabBarController.viewControllers indexOfObject:viewController];
                      // Only the second tab shouldn't pop home 
                      return ((indexOfNewViewController != 1) ||
                              (indexOfNewViewController != tabBarController.selectedIndex));
                  }
                  

                  这篇关于如何停止弹出到导航控制器的标签栏的第二次点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UITabBarController UINavigationController 设计建议 下一篇:视图不在窗口层次结构中的 iOS

                  相关文章

                    <bdo id='xevs4'></bdo><ul id='xevs4'></ul>
                  <tfoot id='xevs4'></tfoot>

                    <i id='xevs4'><tr id='xevs4'><dt id='xevs4'><q id='xevs4'><span id='xevs4'><b id='xevs4'><form id='xevs4'><ins id='xevs4'></ins><ul id='xevs4'></ul><sub id='xevs4'></sub></form><legend id='xevs4'></legend><bdo id='xevs4'><pre id='xevs4'><center id='xevs4'></center></pre></bdo></b><th id='xevs4'></th></span></q></dt></tr></i><div id='xevs4'><tfoot id='xevs4'></tfoot><dl id='xevs4'><fieldset id='xevs4'></fieldset></dl></div>

                    <small id='xevs4'></small><noframes id='xevs4'>

                  1. <legend id='xevs4'><style id='xevs4'><dir id='xevs4'><q id='xevs4'></q></dir></style></legend>