繁体   English   中英

更改方向时,窗口不会更新子视图CGRect

[英]window does not update subview CGRect when changes orientation

当我以窗口方向添加子视图时,在窗口中的屏幕方向正常工作,它不适用于子视图。 i定向时更改子视图CGRectMake。

self.myviewctrl = [[MYViewController alloc] initWithNibName:@"MYViewController"    bundle:nil];

if (InterfaceOrientation==LandScape) {
    self.myviewctrl.view.frame = CGRectMake(0, 0, 568, 320);
    self.myviewcrl.anothersubview.frame = CGRectMake(430, 0,50,320);
} else{
    self.myviewctrl.view.frame = CGRectMake(0, 0, 320, 480);
    self.myviewcrl.anothersubview.frame = CGRectMake(260, 0,60,411);
}

self.window = [UIApplication sharedApplication].keyWindow;
if (!self.window) {
    self.window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
[[[self.window subviews] objectAtIndex:0] addSubview:self.myviewctrl.view];

self.myviewctrl

self.myviewcrl

不同的viewControllers还是命名错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM