[英]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.