iOS更改方向时更改UI的最佳方式

改变方向时更改用户界面的最佳方法是什么?

例如,使用两个不同的UIView一个肖像和一个风景,如果方向改变,或者使用一个UIView并更改UI控件的大小和位置,则显示两者之一?

任何其他的想法?

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { NSLog(@"Change to custom UI for landscape"); } else if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { NSLog(@"Change to custom UI for portrait"); } } 

我总是build议在视图控制器视图中为所有子视图使用autoresizingmask。 通过正确设置,所有视图都将从方向自动resize,并且不需要额外的旋转特定的子视图(一个纵向视图和一个横向视图)。