横竖屏切换解决方案

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
        [landscape removeFromSuperview];
        [self.view addSubview:portrait];
    }
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        [portrait removeFromSuperview];
        [self.view addSubview:landscape];
    }
}

#define UIInterfaceOrientationIsPortrait(orientation)  ((orientation) == UIInterfaceOrientationPortrait || (orientation) == UIInterfaceOrientationPortraitUpsideDown)
#define UIInterfaceOrientationIsLandscape(orientation) ((orientation) == UIInterfaceOrientationLandscapeLeft || (orientation) == UIInterfaceOrientationLandscapeRight)


你可能感兴趣的:(横竖屏切换解决方案)