Ios iPad-UINavigationBar超过宽度,ViewController作为半屏幕子视图

Ios iPad-UINavigationBar超过宽度,ViewController作为半屏幕子视图,ios,ipad,ios5,Ios,Ipad,Ios5,我正在将ViewController作为子视图添加到主视图中,如下所示: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Backstage" bundle:nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"BackstageHomeViewController"]; vc.view

我正在将ViewController作为子视图添加到主视图中,如下所示:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Backstage" bundle:nil];
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"BackstageHomeViewController"];
    vc.view.frame = CGRectMake(0, 0, 480, self.view.frame.size.height);

    [self.view addSubview:vc.view];
问题是,UINavigationBar仍然具有原始的全屏宽度,并且在边缘处被切断


如何更改宽度以匹配它所包含的视图?

vc.view.frame=CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)

耶--iOS 6刚刚通过新的容器视图解决了这个问题,它允许您在
UIView
中嵌入
UIViewController
。自动调整大小。

是否打开新的故事板或使用应用程序启动时使用的故事板?新的故事板。我将其用作子视图中显示所有ViewController的“区域”,该区域仅占据屏幕的左半部分。我没有尝试过,但无法修改初始ViewController框架(自由形式设置)?是的,自由形式。我认为只有背景没有被调整。从屏幕截图中可以看到,标题居中,因此UINavigationBar的大小是正确的。我正在尝试使它只占屏幕的一半,这很好。问题是,UINavigationBar的背景被切断,但我想我需要一个自定义背景…谢谢,这使我能够将视图的宽度扩展到其父视图控制器的宽度。