我将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仍然具有原始的全屏宽度,并且在边缘处显示为切断。
如何更改宽度以匹配其中包含的视图?
答案 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
。自动调整大小。