[英]viewcontroller and autolayout rotation issue
嗨,我正在用以下代码创建自定义viewcontroller层次结构。 但是,我在子视图中设置的自动布局似乎不起作用。 当我旋转设备时,子视图不会拉伸以适合屏幕。
_postVC = [[POSTViewController alloc] initWithNibName:@"POSTViewController" bundle:nil];
[self addChildViewController:_postVC];
[_postVC didMoveToParentViewController:self];
[self.mainView addSubview:_postVC.view];
_postVC.view
不拉伸是相同的宽度self.mainView
旋转之后。
你需要:
_postVC.view.frame = self.mainView.bounds // 1 _postVC.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight // 2
在将_postVC.view
添加为_postVC.view
的子视图self.mainView
。
这样,1.使_postVC.view
适应self.mainView
,并2.将_postVC.view
配置为在调整self.mainView
的大小时垂直和水平地调整大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.