如何创建具有2个tabbars子视图iPhone主菜单画面?
-
25-09-2019 - |
题
我做了两个应用程序,它们中的每一个是基于的TabBar。结果 现在我想将它们合并到一个应用程序,将是结构类似:点击 - 主菜单有2个buttones。结果 - 按钮1:标签栏的应用程序没有1.点击 - 按钮2:标签栏的应用程序没有2
。这是每一个标签栏的应用程序,我要上的导航栏,将带我到主菜单的左边的主页按钮。
我发现这个链接 http://www.pushplay.net/blog_detail.php ?ID = 27 但它不是对我好.. 我会很高兴,如果你能发布一些简单的代码,我的问题..结果 感谢。
解决方案
应用的1和2需要被viewcontrollers,其中的每一个具有的TabBar基于周围。根窗口可以然后只分配/ init和然后[self.navigationController pushViewController:viewController animated:YES];
启动的TabBar控制器。
如果你一直依靠IB建立你的TabBar的应用程序,它很难将其转化为视图控制器。我编程方式创建我的tabbars(我只是觉得它更容易)这样
tabBarController = [[UITabBarController alloc] init]; // creates your tab bar so you can add everything else to it
searchTableViewController = [[SearchTableViewController alloc] init];
UINavigationController *searchTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchTableViewController] autorelease];
[searchTableViewController release];
searchMapViewController = [[SearchMapViewController alloc] init];
UINavigationController *mapTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchMapViewController] autorelease];
[searchMapViewController release];
atestViewController = [[AboutTableViewController alloc] init];
UINavigationController *AboutNavController = [[[UINavigationController alloc] initWithRootViewController:atestViewController] autorelease];
[atestViewController release];
tabBarController.viewControllers = [NSArray arrayWithObjects:searchTableNavController, mapTableNavController, AboutNavController, nil];
[self.view addSubview:tabBarController.view];