setStatusBarOrientation not working

百般思念 提交于 2019-12-24 18:30:53

问题


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

[application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 

and also shouldAutorotateToInterfaceOrientation is set to return NO.

Please help me out.


回答1:


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.

Also change your shouldAutorotateToInterfaceOrientation method:

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


来源:https://stackoverflow.com/questions/12034220/setstatusbarorientation-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!