setStatusBarOrientation不起作用 [英] setStatusBarOrientation not working

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

问题描述

我正在尝试将状态栏的方向固定为纵向",但没有成功.我已经尝试过:

I'm trying to fix the orientation of status bar to Portrait, but not succeeded. I have tried:

[application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 

以及 shouldAutorotateToInterfaceOrientation 都设置为返回 NO .

请帮帮我.

推荐答案

如果要在显示特定视图时更改方向,则应在[UIViewController viewWillAppear:]覆盖方法内调用[UIApplication setStatusBarOrientation:animated:].对于强制特定方向的每个视图控制器.当视图被推入堆栈或从堆栈弹出时,这将导致更改.确保在覆盖方法中调用super.

If you want to change the orientation when a particular view is showing, you should call [UIApplication setStatusBarOrientation:animated:] inside your [UIViewController viewWillAppear:] override method for each of the view controllers that force a particular orientation. That will cause a change when a view is being pushed onto the stack and when it's being popped off it. Make sure you call super in your override method.

还更改您的shouldAutorotateToInterfaceOrientation方法:

Also change your shouldAutorotateToInterfaceOrientation method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

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

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