为什么你需要两个 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;
}
你为什么要使用2个viewcontrollers一个看法?当用户转动设备时,您也可以将view2旋转到风景。 – wkberg
因为,我的视图没有正确显示 –