objective-c – setStatusBarOrientation:animated:在iOS 6中不起作用

用户完成观看视频(允许以横向模式观看)之前,我已经使用此代码强制将方向更改回纵向,然后将视频视图控制器从导航控制器上弹出:
//set statusbar to the desired rotation position
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBaranimationNone];

这完美地运行到iOS 5.1.1.我甚至试图在另一篇文章中阅读后使用新的现有/解除方法,现在应该使用这些方法

[self presentViewController:mVC animated:NO completion:NULL];
[self dismissViewControllerAnimated:NO completion:NULL];

问题是它根本不起作用.将视频查看器旋转到横向然后弹出后,我的设置视图(表格视图控制器)返回,但也处于横向模式.

我甚至试过了Here的小费

“setStatusBarOrientation:animated:方法不是直接弃用.但是现在只有当最顶层全屏视图控制器的supportedInterfaceOrientations方法返回0时,它才有效.这使得确保状态栏方向一致到调用者手中的责任“.

所以我已经尝试设置一个标志来强制supportedInterfaceOrientations返回0(在调用上面的第一个代码块之前),但它也不起作用.

有人有解决方案吗?
感谢您的时间和精力.

解决方法

setStatusBarOrientation方法稍微改变了一下行为.根据Apple文档:

The setStatusBarOrientation:animated: method is not deprecated outright. It Now works only if the supportedInterfaceOrientations method of the top-most full-screen view controller returns 0

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...