如何在iOS中刷新屏幕方向

如何在iOS中刷新屏幕方向,ios,orientation,Ios,Orientation,在我的应用程序中,一些ViewController应该以固定方向显示,但其他ViewController可以自由旋转屏幕方向。当我在某个ViewController上使用 NSNumber *value = [NSNumber NumberWithInt:UIInterfaceOrientationPortrait]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 这把锁的方向很好。但是,当我返回到上一个Vie

在我的应用程序中,一些ViewController应该以固定方向显示,但其他ViewController可以自由旋转屏幕方向。当我在某个ViewController上使用

NSNumber *value = [NSNumber NumberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
这把锁的方向很好。但是,当我返回到上一个ViewController或移动到可自由旋转的其他ViewController时,方向不会返回到实际方向。
当ViewController继续运行时,我只是释放方向锁,但是
[[UIDevice currentDevice]方向]
只返回我设置的值,而不是当前设备的实际方向<代码>[UIViewController尝试旋转到设备定向]也不起作用。
如何获取当前设备的真实方向和刷新布局?

提前谢谢。

这就是您要找的吗?不。我以前试过这个,但它只有在设备改变方向时才起作用。我只知道设备的“真实”方向,而不改变方向。[[UIDevice currentDevice].orientation]只返回我以编程方式设置的值。这就是您要查找的吗?不。我以前试过这个,但它只有在设备改变方向时才起作用。我只知道设备的“真实”方向,而不改变方向。[[UIDevice currentDevice].orientation]只返回我以编程方式设置的值。