开发者

TabBarController within the RootViewController of a SplitViewController

开发者 https://www.devze.com 2023-01-12 23:10 出处:网络
I\'d like to develop an iPad app which would be composed of a SplitViewController. I\'d like to add a TabBarController in the RootViewController.

I'd like to develop an iPad app which would be composed of a SplitViewController. I'd like to add a TabBarController in the RootViewController.

I'm at the very beginning of the development. So I've started to simply create a new project, add a SplitViewController via Interface Builder and test the app, no problem of course. Then I've tried to add the TabBarController to the RootView, no problem either via the Interface Builder. The problem I have there is that I can't make the app rotate with the device. I assume that I have to change something in the code but I don't know what :-( I've noticed that the method shouldAutorotateToInterfaceOrien开发者_Python百科tation is never called when the device rotates. I'm sorry to ask this question but I'm very new in developping iPad/iPhone apps.

Best regards


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消