1

我有一个应用程序在纵向模式下有一些视图,我想在横向模式下呈现模态视图控制器......对于 IOS 5.0 和 5.1 完美运行,在 IOS 6 中它打开 modalView 但在纵向模式下。您需要知道:我使用情节提要,并将该 VC 设置为 Landscape... 在应用程序委托中,我添加了:

-(NSUInteger)application:(UIApplication *)application    supportedInterfaceOrientationsForWindow:(UIWindow *)w
{return UIInterfaceOrientationMaskPortrait;}

如果我添加| UIInterfaceOrientationMaskLandscape,我可以在其他视图中旋转应用程序。

然后对于摘要,我禁用了所有支持的界面方向。在这里我尝试设置纵向和横向左侧,效果很好,但在这种情况下,我可以将所有视图旋转到左侧并返回纵向。

在我想在横向吃午饭的 ViewCONtroller 之后,我有适用于 IOS 6 的方法:

-(NSUInteger)supportedInterfaceOrientations
{return UIInterfaceOrientationLandscapeLeft;}

-(BOOL)shouldAutorotate
{return YES;}

当我点击按钮午餐modalView运行后,我得到这个错误:“支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES”

我知道关于在该方法上返回 YES,但如果我设置为 NO,则不会发生任何事情。我想考虑一下:我的应用程序需要在 IOS 5 及更高版本上运行。

任何人都可以帮助我吗?任何建议都值得赞赏;)

非常感谢

4

1 回答 1

3
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self transformView2ToLandscape];}

-(void) transformView2ToLandscape {

NSInteger rotationDirection;
UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];

if(currentOrientation == UIDeviceOrientationLandscapeLeft){
    rotationDirection = 1;
}else {
    rotationDirection = -1;
}

CGAffineTransform transform = [arController.viewController.view transform];
transform = CGAffineTransformRotate(transform, degreesToRadians(rotationDirection * 90));
[arController.viewController.view setTransform: transform];}

这对我来说很好。

于 2013-01-16T10:42:35.920 回答