[英]Auto Rotate while switching between View Controllers
我在编程方面遇到了问题。 我有两个视图控制器。 第一个仅在横向左/右运行,另一个仅在纵向运行。 如果我在视图之间切换,方向不会自动改变。 只有当我转动设备时,方向才会改变。 之后,方向是固定的。 当我在控制器之间切换时,是否可以自动更改方向?
例如,当我在横向视图控制器中按BackButton并切换到纵向视图控制器时,方向自动从横向切换到纵向?
抱歉我的英文不好,这不是我的母语。
蒂姆,谢谢
在第二个视图中尝试以下Code for Portrait。
- (void)viewWillAppear:(BOOL)animated {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
在第一个视图中尝试以下横向代码。
- (void)viewWillAppear:(BOOL)animated {
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscape];
}
if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
{
self.view.frame = CGRectMake(0,0,1024,768);
}
else
{
self.view.frame = CGRectMake(0,0,768,1024);
}
----使用这个代码你要改变的地方---
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.