2012-10-16 153 views
1

我有一个UITabController和3 UIViewController s,每个标签一个。添加子视图到UITabBarController

在这些标签中的一个,我想添加一个子视图(其实我想与其他视图替换选项卡的内容

这是我在做什么。

QuestionClass *oView = [[QuestionClass alloc] initWithNibName:@"QuestionClass" bundle:[NSBundle mainBundle]]; 
    [self presentModalViewController:oView animated:NO]; 

它的工作原理,但标签栏是隐藏的,你知道你展现它

+0

检查你的UIView的帧大小。 –

+1

有可能设置一个特定的大小? – Max

+0

对于modalViewController?编号 –

回答

3

presentModalViewController:文档说:

在iPhone和iPod touch设备中,modalViewController的视图始终呈现为全屏。在iPad上,演示文稿取决于modalPresentationStyle属性中的值。

如果您使用的是iPhone(iPod),并且希望控制器保留在选项卡控制器的视图空间内,则应该考虑让导航控制器将其推入。

+0

或者只是将其作为子视图添加到整个框架中并放到前面。 – Kevin

+0

presentModalViewController:无论如何已弃用。使用presentViewController:相反,然后您可以定义一个演示文本上下文,该上下文可能仅限于当前视图的边界。但是,海报的做法仍然是错误的。 UINavigationController是要走的路。 – Krumelur

+0

好的我已经完成了 QuestionClass * oView = [[QuestionClass alloc] initWithNibName:@“QuestionClass”bundle:[NSBundle mainBundle]]; [UIView transitionWithView:self.view duration:0.5 options:UIViewAnimationOptionTransitionCurlUp 动画:^ {[self.view addSubview:oView.view]; } completion:nil];' 但是现在在执行QuestionClass时,每次我用[self XXX]调用一个方法时,我都会得到一个不好的访问。看来自己不是问题类... – Max

2

使用演示视图控制器不能使用TabBar。 TabBar用来切换视图。

+0

您忘记了一个字吗? tabbar使用XXX切换? – Max

1

其中一个可能性是:

广场navigationController为每个选项卡(以及相应的viewControllers被推为相应navigationController)

然后 - 在必要选项卡您可以推动未来的ViewController,而的TabBar仍然可见(和在其他选项卡中,信息不会更改)。

请参阅与NIB结构附截图:

enter image description here

相关问题