[英]ios: Make a view contained by another view rotate
我有一個小問題,找不到解決方法。 我有一個視圖在另一個視圖內部,該視圖在主視圖旋轉時不會旋轉...這樣說有點混亂,所以我將編寫一些代碼:
//in my ViewController:
UIView insideView = [[UIView alloc] initWithFrame:self.view.frame];
insideView.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.0];
...
[self.view addSubview:insideView];
現在,我不知道為什么,如果我旋轉我的iPhone(模擬器), insideView不會跟隨主要的self.view 。
嘗試以下方法
[self.view setAutoresizesSubviews:YES];
[self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
setAutoresizesSubviews屬性控制每個視圖的邊界更改時是否自動調整大小。 setAutoresizingMask屬性控制每個對象如何自動調整大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.