Допустим, у вас есть PortraitViewController и LandscapeViewController.
Вам потребуется следующее:
@interface PortraitViewController : UIViewController {
BOOL isShowingLandscapeView;
LandscapeViewController *landscapeViewController;
}
@implementation PortraitViewController
- (void)viewDidLoad
{
[super viewDidLoad];
landscapeMainViewController = [[LandscapeMainViewController alloc] initWithNibName:@"LandscapeMainViewController" bundle:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[landscapeMainViewController release]; landscapeMainViewController = nil;
[super dealloc];
}
- (void)orientationChanged:(NSNotification *)notification
{
[self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0];
}
- (void)updateLandscapeView
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView)
{
[self presentModalViewController:landscapeMainViewController animated:YES];
isShowingLandscapeView = YES;
}
else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView)
{
[self dismissModalViewControllerAnimated:YES];
isShowingLandscapeView = NO;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
@interface LandscapeViewController : UIViewController
@end
@implementation LandscapeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
self.wantsFullScreenLayout = YES;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
return self;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
@end
Кредиты: http://www.edumobile.org/iphone/iphone-programming-tutorials/alternativeviews-in-iphone/