为什么你需要两个ViewControllers 只是为了定位..?
这里简单的场景,
创建 2 个视图
- 肖像 &&
- 风景视图,根据您的要求。
遵循这样的事情。
-(BOOL)shouldAutorotate{
return YES;
}
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self orientationChanged:toInterfaceOrientation];
}
-(void)orientationChanged:(UIInterfaceOrientation)orientation{
NSLog(@"orientation change");
// UIDeviceOrientation deviceOrientation = [[object object] orientation];
if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"Changed Orientation To Portrait");
self.viewPortrait.hidden = NO;
self.viewLandscape.hidden = YES;
}
else if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight){
NSLog(@"Changed Orientation To Landscape");
self.viewPortrait.hidden = YES;
self.viewLandscape.hidden = NO;
}
}
并且您应该设置所有需要的方向。
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}