iPad - UINavigationBar超出宽度,ViewController为半屏子视图

时间:2012-09-16 15:48:33

标签: ios ipad ios5

我将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仍然具有原始的全屏宽度,并且在边缘处显示为切断。

enter image description here

如何更改宽度以匹配其中包含的视图?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

Yay - iOS 6刚刚使用新的容器视图解决了这个问题,允许您在UIViewController内嵌入UIView。自动调整大小。