• <legend id='mx3B4'><style id='mx3B4'><dir id='mx3B4'><q id='mx3B4'></q></dir></style></legend>

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

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

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

      1. 如何以编程方式删除在父类 NIB 文件中创建的选项卡栏项?

        时间:2023-10-03

            <legend id='u5yJW'><style id='u5yJW'><dir id='u5yJW'><q id='u5yJW'></q></dir></style></legend>

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

                <tfoot id='u5yJW'></tfoot>

                  本文介绍了如何以编程方式删除在父类 NIB 文件中创建的选项卡栏项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的 iPhone 应用程序中,我有一个带有 三个标签 的公共标签栏,在按下按钮后会从多个视图中呈现.我遵循的方法是 Tweetie 应用程序的工作流程,在 Robert Conn 帖子.

                  Within my iPhone application I have a common tab bar with three tabs that is presented from several views after pressing a button. The approach I followed was the workflow of Tweetie application, described in Robert Conn post.

                  注意主控制器是一个导航控制器;选项卡栏放置在导航堆栈的视图控制器的 NIB 文件中,选项卡之间的切换效果在委托的 didSelectItem 方法中处理.

                  Note that the main controller is a navigation controller; the tab bar is placed in a view controller's NIB file of the navigation stack, and the effect of switching between tabs is handled in a delegate didSelectItem method.

                  @interface GameTabBarController : UIViewController<UITabBarDelegate> {
                    UITabBar *tabBar;
                    UITabBarItem *lastGameTabBarItem;
                    UITabBarItem *previousGamesTabBarItem;
                    UITabBarItem *myBetsTabBarItem;
                  
                    NSArray *viewControllers;
                    UIViewController *currentViewController;
                  }
                  
                  @implementation GameTabBarController
                    ...
                  
                    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
                      UIViewController *viewController = nil;
                  
                      // Get the view controller linked to the tab bar item pressed
                      ...
                  
                      // Switch to the view
                      [self.currentViewController.view removeFromSuperview];
                      [self.view addSubview:viewController.view];
                      self.currentViewController = viewController;
                    }
                  
                    ...
                  @end
                  

                  由于标签栏的视图必须根据应用程序来自的视图控制器进行自定义,我已将此 GameTabBarController 设置为具有该标签栏的 NIB 文件的父类.然后,我创建了几个子类:

                  Since the views of the tab bar must be customized according to the view controller the application came from, I have made this GameTabBarController a parent class with that NIB file that have the tab bar. Then, I have created several children classes:

                  @interface FirstGameTabBarController : GameTabBarController {
                    ...   
                  }
                  
                  @interface SecondGameTabBarController : GameTabBarController {
                    ...   
                  }
                  
                  ...
                  

                  我的问题是,在某些子类中,我想删除与父类关联的 NIB 文件的第三个选项卡.但由于没有涉及 UITabBarController,我无法遵循您可以在网络上找到的典型方法,即删除标签栏项目的视图控制器.

                  My problem is that in some of the children classes I would like to remove the third tab of the NIB file associated with parent class. But since there is no UITabBarController involved, I cannot follow typical approaches you can found on the web, i.e. removing the view controller of the tab bar item.

                  我该怎么做?是否可以删除之前在 NIB 文件中添加的元素?

                  How can I do that? Is it possible to remove elements that has been previously added in a NIB file?

                  谢谢!!

                  更新解决方案非常简单......我只需替换标签栏项目,而不是视图控制器:

                  UPDATE The solution was so easy... I have just to replace the tab bar items, instead of the view controllers:

                  NSMutableArray *items = [NSMutableArray arrayWithArray:self.tabBar.items];
                  [items removeObjectAtIndex:2];
                  [self.tabBar setItems:items];
                  

                  感谢@Praveen S 为我指明了正确的方向.

                  Thanks to @Praveen S for pointing me in the right direction.

                  推荐答案

                  以下代码有解决方案:

                  NSMutableArray *tbViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
                  [tbViewControllers removeObjectAtIndex:2];
                  [self.tabBarController setViewControllers:tbViewControllers];
                  

                  这篇关于如何以编程方式删除在父类 NIB 文件中创建的选项卡栏项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在iphone视图中的两个点击点之间绘制自动线 下一篇:@property 和 @synthesize 的意义何在?

                  相关文章

                  <tfoot id='FE6Fw'></tfoot>

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

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