Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.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 锁定接口方向?_Iphone_Orientation_Xcode4.5 - Fatal编程技术网

Iphone 锁定接口方向?

Iphone 锁定接口方向?,iphone,orientation,xcode4.5,Iphone,Orientation,Xcode4.5,在我的应用程序的初始视图中,我希望界面仅为纵向,但在视图控制器上,之后可以是任何方向。我尝试使用此代码锁定它,但它不起作用,并且视图仍然可以旋转: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 代码不起作用的原因很可能

在我的应用程序的初始视图中,我希望界面仅为纵向,但在视图控制器上,之后可以是任何方向。我尝试使用此代码锁定它,但它不起作用,并且视图仍然可以旋转:

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

代码不起作用的原因很可能是因为您正在运行iOS 6。请尝试以下代码:

- (BOOL)shouldAutorotate {
    return NO;
}