Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone SetStatusBaroOrientation不工作_Iphone_Statusbar - Fatal编程技术网

Iphone SetStatusBaroOrientation不工作

Iphone SetStatusBaroOrientation不工作,iphone,statusbar,Iphone,Statusbar,我试图将状态栏的方向改为纵向,但没有成功。我试过: [application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 而且shouldAutorotateToInterfaceOrientation设置为返回NO 请帮助我。如果您想在显示特定视图时更改方向,您应该在[UIViewController ViewWillAspect:]中调用[UIApplication setStatusBarOr

我试图将状态栏的方向改为纵向,但没有成功。我试过:

[application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 

而且
shouldAutorotateToInterfaceOrientation
设置为返回
NO


请帮助我。

如果您想在显示特定视图时更改方向,您应该在[UIViewController ViewWillAspect:]中调用[UIApplication setStatusBarOrientation:animated:]覆盖方法,以覆盖每个强制特定方向的视图控制器。当视图被推到堆栈上或从堆栈中弹出时,这将导致更改。确保在覆盖方法中调用super

还要更改您的shouldAutorotateToInterfaceOrientation方法:

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

shouldAutorotateToInterfaceOrientation
应将
YES
返回到viewController支持的方向,如果每个方向都不正确,则返回
NO
。如果支持纵向,则如果方向为纵向,则返回
YES