【发布时间】:2010-04-04 08:05:51
【问题描述】:
所以,我希望我的应用程序以 UIViewController(没有看到标签栏)开始,然后输入带有导航栏和标签栏的 UITableView。问题是标签栏在应用程序启动时可见,任何人都可以帮助解决这个问题......
【问题讨论】:
标签: iphone objective-c cocoa-touch uikit tabbar
所以,我希望我的应用程序以 UIViewController(没有看到标签栏)开始,然后输入带有导航栏和标签栏的 UITableView。问题是标签栏在应用程序启动时可见,任何人都可以帮助解决这个问题......
【问题讨论】:
标签: iphone objective-c cocoa-touch uikit tabbar
我认为您应该将 -presentModalViewController:animated: 发送到您的主 UIViewController,并将标签栏控制器作为参数,或者只是这样做:
[myWindow addSubview: myTabBarController.view];
【讨论】:
使您的应用程序成为基于导航的应用程序(而不是基于标签栏的应用程序),然后在 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];) 可能首先设置框架。
【讨论】: