SplitViewController的RootViewController中的TabBarController

时间:2010-08-26 08:44:59

标签: ipad ios-simulator

我想开发一款由SplitViewController组成的iPad应用程序。我想在RootViewController中添加TabBarController

我正处于开发的最初阶段。所以我开始简单地创建一个新项目,通过SplitViewController添加Interface Builder并测试应用程序,当然没问题。然后我尝试将TabBarController添加到RootView,通过Interface Builder没问题。我遇到的问题是我不能让应用程序随设备一起旋转。我假设我必须在代码中改变一些东西,但我不知道:-( 我注意到,当设备旋转时,永远不会调用方法shouldAutorotateToInterfaceOrientation。 我很抱歉提出这个问题,但我在开发iPad / iPhone应用程序时非常新。

祝你好运

1 个答案:

答案 0 :(得分:1)

UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:annualViewController];
[navigationController1.navigationBar addSubview:imageView1];
[list addObject:navigationController1];
[imageView1 release];

UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:rootViewController];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navigation bar.png"]];
imageView2.frame = CGRectMake(0, 0, 320, 44);
[navigationController2.navigationBar addSubview:imageView2];
[list addObject:navigationController2];
[imageView2 release];

tabBarController.viewControllers=list;

detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
rootViewController.detailViewController = detailViewController;
annualViewController.detailViewController=detailViewController;

splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:tabBarController, detailViewController, nil];
splitViewController.delegate = detailViewController;

// Add the split view controller's view to the window and display.

[window addSubview:splitViewController.view];
[window makeKeyAndVisible];