在将视频 View Controller 从导航 Controller 中弹出之前,我已经使用此代码在用户看完视频(它允许以横向模式查看)时强制将方向更改回纵向:
//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
之前一直有效。在阅读另一篇文章后,我什至尝试使用新的 present/dismiss 方法:
[self presentViewController:mVC animated:NO completion:NULL];
[self dismissViewControllerAnimated:NO completion:NULL];
问题是它根本不起作用。在我将视频查看器旋转到横向然后弹出它之后,我的设置 View ( TableView Controller )又回来了,但也是横向模式。
我什至尝试过来自 Here 的技巧
“setStatusBarOrientation:animated:
方法并未完全弃用。但是,它现在仅在最顶层全屏 View Controller 的 supportedInterfaceOrientations
方法返回 0 时才有效。这表明确保状态栏方向在调用者手中保持一致的责任。”
所以我尝试设置一个标志来强制 supportedInterfaceOrientations
到 return 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
关于objective-c - setStatusBarOrientation :animated: not working in iOS 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12563954/