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

Las*_*zlo 2 user-interface orientation ios

更改方向时更改UI的最佳方法是哪种?

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

还有其他想法吗?

Mic*_*lum 5

- (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");

    }
}
Run Code Online (Sandbox Code Playgroud)