2013-05-21 63 views
1

所有人。我有两个意见。第一个视图仅支持横向,第二个视图支持所有的方向。但是,当第二个视图是纵向并按下一个按钮时,它将跳转到第一个纵向,这意味着横向。未能从纵向视图跳转到横向视图

我在第一个ViewController中添加了以下两个方法。

- (BOOL)shouldAutorotate 
{ 
     return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
} 

不知有没有人能帮助我,因为这个问题困扰了我很久。 感谢转发!

+0

+1,希望它可以帮助你在你的声誉。 :) – mAc

回答

0

我不知道我是否有ü正确与否。直到我得到的是,你有2个viewControllers,第一个viewController只支持景观而第二个viewController支持所有的方向。但是你在维护这个问题上有问题。检查你是否已经在你的代码中实现了这一点,如果你仍然发现任何问题,做回恢复,如果它解决善意接受答案并投票了): -

1)你的第一个viewController应该有这样的: - //为iOS 6

-(BOOL)shouldAutorotate{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

为< iOS 6的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft); 

} 

2)你的第二个的viewController应该有这样的: - 为iOS 6

-(BOOL)shouldAutorotate{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

为< iOS6的

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
+0

我试过了你的方法,但不幸的是它没有工作。当我从第二个视图纵向跳回到第一个视图时,该设备是纵向的,而视图是横向的... – Calios

+0

我认为你必须在纵向模式下有第一个视图元素。你是否。?? – mAc

+0

给我你的电子邮件ID我已根据你的要求为你制作了一个应用程序。是的,请接受我的回答,并请投票。 – mAc

0

我从来没有在应用程序中测试这一点,但尝试使用:

[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait]; 
+0

它警告我:'UIDevice'可能不会响应'setOrientation'...我试图修复它到[UIDevice currentDevice] .orientation = UIDeviceOrientationLandscapeLeft;我得到了“赋值给只读属性”的错误.... – Calios

+0

您正在开发的iOS是什么? – Mutawe

+0

iPad应用程序。自转问题困扰了我很长一段时间,我近乎为此而疯狂...... – Calios

相关问题