我正在尝试一些奇怪的东西.我想创建一个适合我所有屏幕的视图(减去statusBar减去navBar).这就是我在我的内心所做的viewDidLoad:
CGFloat navHeight = self.navigationController.navigationBar.frame.size.height;
UIView *test = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight-20-navHeight)];
test.backgroundColor = [UIColor greenColor];
//test.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:test];
Run Code Online (Sandbox Code Playgroud)
如果我留下自动调整行注释,这可以正常工作,但是当我旋转时,它不再适合(这是预期的).
如果我取消注释自动调整行,当我第一次以纵向模式启动时,我的视图大小就像320x430,当我第一次以横向模式启动时,它就像480x200 ......"首次启动"我的意思是"来自另一个视图".
我尝试添加灵活的边距,但它没有修复(无论如何我希望它是全屏的,所以(x,y)将永远是(0,0).