Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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_Objective C_Ios_Xcode4.2_Storyboard - Fatal编程技术网

Iphone 无法仅旋转一个视图

Iphone 无法仅旋转一个视图,iphone,objective-c,ios,xcode4.2,storyboard,Iphone,Objective C,Ios,Xcode4.2,Storyboard,我使用的是XCode 4.2(带有故事板) 我试图只旋转其中一个视图(而不是所有视图),但它似乎不起作用。。。要么旋转其中一个视图,要么旋转所有视图 我已经检查了摘要中所有支持的视图,并且在info中我确保应用程序“支持的接口方向”都在那里 在与视图相关的类中,我编写了旋转此特定视图的函数: -(BOOL) shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation{ return(int

我使用的是XCode 4.2(带有故事板)

我试图只旋转其中一个视图(而不是所有视图),但它似乎不起作用。。。要么旋转其中一个视图,要么旋转所有视图

我已经检查了摘要中所有支持的视图,并且在info中我确保应用程序“支持的接口方向”都在那里

在与视图相关的类中,我编写了旋转此特定视图的函数:

-(BOOL) shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation{
return(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown||
interfaceOrientation != UIInterfaceOrientationPortrait||
interfaceOrientation != UIInterfaceOrientationLandscapeRight||
interfaceOrientation != UIInterfaceOrientationLandscapeLeft)
}

当我旋转屏幕时,它仍然不旋转。。。有什么线索吗?

您的方法可以简化为:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return YES;
}
您要做的是让设备支持您想要的所有方向中的方向,然后在特定视图中,使用上述方法允许您想要该视图的方向。例如,如果您只需要特定视图的横向模式,可以使用:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

希望有帮助

shouldAutorotateToInterfaceOrientation
中,您必须返回您想要支持的所有方向

因此,如果您希望您的应用程序只在纵向上运行,请使用以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
如果要支持所有可能的方向,请执行以下操作:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }
你确定那些“不相等”运算符吗?你不应该使用“==”或者简单地返回YES吗?我尝试了“YES”并尝试了==。。。没有人在工作