0

我将 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 仍然具有原始的全屏宽度,并且在边缘看起来被切断了。

在此处输入图像描述

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

4

2 回答 2

0

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

于 2012-09-16T17:42:33.033 回答
0

是的——iOS 6 刚刚使用新的 Container View 解决了这个问题,它允许您UIViewControllerUIView. 自动调整大小。

于 2012-09-19T21:07:23.807 回答