TabBarController within the RootViewController of a SplitViewController

主宰稳场 提交于 2019-12-10 11:56:42

问题


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 shouldAutorotateToInterfaceOrientation 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


回答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];


来源:https://stackoverflow.com/questions/3573452/tabbarcontroller-within-the-rootviewcontroller-of-a-splitviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!