SplitViewController的RootViewController中的TabBarController [英] TabBarController within the RootViewController of a SplitViewController

查看:78
本文介绍了SplitViewController的RootViewController中的TabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个iPad应用程序,它将由 SplitViewController 组成。我想在RootViewController中添加一个 TabBarController

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.

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

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.

祝你好运

推荐答案

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

这篇关于SplitViewController的RootViewController中的TabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆