我正在使用容器视图控制器在 3 秒后将子视图添加到我当前的视图控制器:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor = [UIColor greenColor];
[self performSelector:@selector(open) withObject:nil afterDelay:3.0];
}
-(void)open{
ViewController2 *test = [[ViewController2 alloc] init];
test.view.backgroundColor = [UIColor redColor];
[self addChildViewController:test];
[self.view addSubview:test.view];
}
ViewController2 是一个简单的视图,在初始化时只有这个:
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
事情是这样的,如果我以纵向打开第二个视图并旋转到横向,红色会填满屏幕,但是如果我从横向打开第二个视图,则会发生这种情况:
有什么线索吗?