将我的视图控制器的人像旋转为风景和人像模式 [英] Rotate portrait to landscape and portrait mode of my view controller

查看:51
本文介绍了将我的视图控制器的人像旋转为风景和人像模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我的应用程序以纵向模式显示除报告视图以外的所有视图.报告视图仅在我处于设置视图并将设备旋转到横向模式时显示.现在,当我再次将设备旋转到纵向模式时,报告视图将关闭,并显示设置视图.

Normally my application shows all views in portrait mode except report view. Report view shows only when I am on settings view and I rotate my device to landscape mode. Now when I rotate my device to portrait mode again, report view is dismissed and settings view is displayed.

In report view 

> shouldAutorotateToInterfaceOrientation

return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft));



Here at settings view 

    shouldAutorotateToInterfaceOrientation


    if((interfaceOrientation == UIInterfaceOrientationLandscapeRight)||( interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
     {  

     Report *report = [[Report alloc]initWithNibName:@"Report" bundle:[NSBundle mainBundle]]; 
     [self.navigationController pushViewController:report animated:YES];
     [report release];

     }
     return YES;
     }

推荐答案

不要在shouldRotate ...中创建视图控制器,而应在 willRotateToInterfaceOrientation:duration:中创建响应轮换.在您的 shouldAutorotateToInterfaceOrientation:中,当您希望能够旋转到该方向时,只需返回YES即可.在这种情况下,您似乎希望所有方向,或者除了PortraitUpsideDown以外的所有方向.

Don't create your viewcontroller in shouldRotate..., but in willRotateToInterfaceOrientation:duration:, which is where you're supposed to respond to a rotation. In your shouldAutorotateToInterfaceOrientation:, just return YES when you want to be able to rotate to that orientation- in your case, it looks like you want to either all orientations, or all orientations except PortraitUpsideDown.

在您的 willRotateToInterfaceOrientation:duration:中,您可以按一下视图控制器或将其弹出.

In your willRotateToInterfaceOrientation:duration:, you can push your viewcontroller or pop it as needed.

这篇关于将我的视图控制器的人像旋转为风景和人像模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆