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

    • <bdo id='bNOIc'></bdo><ul id='bNOIc'></ul>

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

    2. <tfoot id='bNOIc'></tfoot>

      禁用操作 - 用户点击标签栏项目以转到根视图控制器

      Disable action - user taps on tabbar item to go to root view controller(禁用操作 - 用户点击标签栏项目以转到根视图控制器)

          <legend id='FePU5'><style id='FePU5'><dir id='FePU5'><q id='FePU5'></q></dir></style></legend>
          <tfoot id='FePU5'></tfoot>

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

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

              • 本文介绍了禁用操作 - 用户点击标签栏项目以转到根视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想在用户点击标签栏项目时禁用默认操作.

                I want to disable the default action when user taps the tabbar item.

                例如,我有一个带有 Tab1、Tab2 和 Tab3 的标签栏.在 Tab1 中,用户可以从 View1 导航到 View3(View1 > View2 > View3).如果用户在 View3,并且他点击 Tab1,应用程序会将用户带到 View1(根视图控制器).我想禁用此功能.我不希望 Tab1 上的点击弹出所有视图控制器.我该怎么做?

                For example, i have a tabbar with Tab1, Tab2 and Tab3. In Tab1, user can navigate from View1 to View3 (View1 > View2 > View3). If user is at View3, and he taps the Tab1, the application takes the user to View1 (the root view controller). I want to disable this functionality. I don't want the tap on Tab1 to pop all the view controllers. How can i do that?

                这种行为有点奇怪,但在层次结构较深的情况下是一个方便的捷径!

                This behavior is a little strange, but a handy shortcut in case of deep hierarchy!

                您可以实现以下 UITabBarControllerDelegate 方法来禁用此系统范围的快捷方式:

                You can implement following UITabBarControllerDelegate methods to disable this system wide shortcut:

                #pragma mark -
                #pragma mark UITabBarControllerDelegate
                
                - (BOOL)tabBarController:(UITabBarController *)tbc shouldSelectViewController:(UIViewController *)vc {
                    UIViewController *tbSelectedController = tbc.selectedViewController;
                
                    if ([tbSelectedController isEqual:vc]) {
                        return NO;
                    }
                
                    return YES;
                }
                

                推荐答案

                如果你看一下 UITabBarController 委托有一个方法:

                if you look at the UITabBarController delegate there is a method:

                - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
                

                如果你在你的类中实现了这个,你可以检查 UIViewController 是否已经显示,然后返回 NO,这将阻止这种情况发生.

                If you implement this in your class, you can check if the UIViewController is the already displayed one and then return NO, which will stop this from happening.

                我对嵌入在 UITabBarController 中的 ABPeoplePicker 对象有同样的问题,第二次按下已经显示的联系人"选项卡会使 ABPeoplePicker 控件显示组"

                I had the same problem with a ABPeoplePicker object embedded in a UITabBarController, in that pressing the 'Contacts' tab a second time which was already displayed would make the ABPeoplePicker control show the 'Groups'

                这篇关于禁用操作 - 用户点击标签栏项目以转到根视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                Show UITabBar when UIViewController pushed(推送 UIViewController 时显示 UITabBar)

                  <bdo id='wHcmR'></bdo><ul id='wHcmR'></ul>

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

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

                    • <legend id='wHcmR'><style id='wHcmR'><dir id='wHcmR'><q id='wHcmR'></q></dir></style></legend>
                            <tbody id='wHcmR'></tbody>

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