更改从shouldAutorotateToInterfaceOrientation返回:在运行时

我正在使用shouldAutorotateToInterfaceOrientation:对所有方向做出回答YES。

在运行时,在less数情况下,我只能将画面的返回值更改为YES。

但是,如果我改变这种返回types,并且我的设备不是在物理上转动,我的界面方向不会改变。 如何强制uiView检查shouldAutorotateToInterfaceOrientation:并旋转视图,而不需要UIdevice旋转通知。

非常感谢。

添加这两行代码:

[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 

静态方法从IOS 5开始:
[UIViewController attemptRotationToDeviceOrientation];