setStatusBarOrientation:animated:在iOS 6中不工作 [英] setStatusBarOrientation:animated: not working in iOS 6

查看:1720
本文介绍了setStatusBarOrientation:animated:在iOS 6中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码在用户完成观看视频(允许以横向模式观看)之后,将视频控制器从导航控制器弹出之前,强制将方向更改回人像:

I've used this code to force an orientation change back to portrait when the user is finished watching the video (it allows viewing in landscape mode), before popping the video view controller off the navigation 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方法阅读后的另一篇文章,那些应该使用现在:

This worked perfectly until iOS 5.1.1. I've even tried to use the new present/dismiss methods after reading in another post that those should be used now:

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

问题是它根本不工作。在我将视频查看器旋转为横向,然后将其弹出后,我的设置视图(表视图控制器)返回,但也以横向模式。

The problem is it doesn't work at all. After I rotated the video viewer to landscape and then pop it, my settings view (table view controller) comes back, but also in landscape mode.

我甚至尝试过这里

setStatusBarOrientation:animated:但是它现在只有当最上面的全屏视图控制器的 supportedInterfaceOrientations 方法返回0时才起作用。这使得确保状态栏方向一致的责任

"The setStatusBarOrientation:animated: method is not deprecated outright. However it now works only if the supportedInterfaceOrientations method of the topmost full screen view controller returns 0. This puts the responsibility of ensuring that the status bar orientation is consistent into the hands of the caller."

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

So I've experimented with setting a flag to force supportedInterfaceOrientations to return 0 (before calling the first code block above) but it doesn't work either.

解决方案?
感谢您的时间和精力。

Does anybody have a solution for this? Thanks for your time and effort.

推荐答案

setStatusBarOrientation 方法改变了行为。根据苹果文档:

setStatusBarOrientation method has changed behaviour a bit. According to Apple documentation:


setStatusBarOrientation:animated:方法不被弃用
outright。它现在仅在最顶层全屏视图控制器的supportedInterfaceOrientations
方法返回0时才起作用

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

这篇关于setStatusBarOrientation:animated:在iOS 6中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆