【问题标题】:How to hide a tabbar at the app startup?如何在应用启动时隐藏标签栏?
【发布时间】:2010-04-04 08:05:51
【问题描述】:

所以,我希望我的应用程序以 UIViewController(没有看到标签栏)开始,然后输入带有导航栏和标签栏的 UITableView。问题是标签栏在应用程序启动时可见,任何人都可以帮助解决这个问题......

【问题讨论】:

    标签: iphone objective-c cocoa-touch uikit tabbar


    【解决方案1】:

    我认为您应该将 -presentModalViewController:animated: 发送到您的主 UIViewController,并将标签栏控制器作为参数,或者只是这样做:

    [myWindow addSubview: myTabBarController.view];
    

    【讨论】:

      【解决方案2】:

      使您的应用程序成为基于导航的应用程序(而不是基于标签栏的应用程序),然后在 UITableView 上添加标签栏。

      有添加UITabBar的帮助here

      我这样做:在这种情况下绘制一个表格视图和地图视图(来自 Locati 应用程序)

      <pre></pre>

      tabBarController = [[UITabBarController alloc] init];          // creates your tab bar so you can add everything else to it
      
      searchTableViewController = [[SearchTableViewController alloc] init];               // creates your table view - this should be a UIViewController with a table view in it, or UITableViewController
      UINavigationController *searchTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchTableViewController] autorelease];
      [searchTableViewController release];                                                              // creates your table view's navigation controller, then adds the view controller you made. Note I then let go of the view controller as the navigation controller now holds onto it 
      
      searchMapViewController = [[SearchMapViewController alloc] init];   
      UINavigationController *mapTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchMapViewController] autorelease];
      [searchMapViewController release];                                                    // does exactly the same as the first round, but for your second tab at the bottom of the bar.
      
      tabBarController.viewControllers = [NSArray arrayWithObjects:searchTableNavController, mapTableNavController,  nil]; //add both of your navigation controllers to the tab bar. You can put as many controllers on as you like
      

      我很久以前就发现了这种模式。对不起,我不能指向原文。 然后你需要将 tabbarcontoller 添加到相关视图 ([...view addSubView:tabBarController];) 可能首先设置框架。

      【讨论】:

      • 是的,我的应用程序是一个基于导航的应用程序,主窗口使用标签栏和导航栏调用 UITableView,我认为这就是标签栏显示在启动视图中的原因(它是一个 UIViewController)。如果您能发布一些示例代码,我们将不胜感激..
      • 我的应用程序是基于 TabBar 的应用程序,这是加载没有标签栏控制器可见的 UIView 的问题吗??
      • 是的。制作基于视图的应用程序。将标签栏添加到您想要标签栏的屏幕。
      猜你喜欢
      • 1970-01-01
      • 2013-09-21
      • 2019-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-24
      相关资源
      最近更新 更多