Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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 仅具有横向模式的iPad应用程序,问题_Iphone_Ipad - Fatal编程技术网

Iphone 仅具有横向模式的iPad应用程序,问题

Iphone 仅具有横向模式的iPad应用程序,问题,iphone,ipad,Iphone,Ipad,我正在尝试实现一个只有横向模式的iPad应用程序。我在info.plist中将支持的界面方向设置为横向右模式。启动应用程序时,视图本身处于横向模式。但当我在登录后添加另一个视图(如主视图)时,视图并没有像横向视图那样旋转。它处于纵向模式。在xib文件中,我也将其设置为横向。我已经在登录和主视图控制器中包含了上述代码。 但是主视图在登录后不会旋转。在每个视图控制器中执行此操作 if (interfaceOrientation == UIInterfaceOrientationPortrait) {

我正在尝试实现一个只有横向模式的iPad应用程序。我在info.plist中将支持的界面方向设置为横向右模式。启动应用程序时,视图本身处于横向模式。但当我在登录后添加另一个视图(如主视图)时,视图并没有像横向视图那样旋转。它处于纵向模式。在xib文件中,我也将其设置为横向。我已经在登录和主视图控制器中包含了上述代码。
但是主视图在登录后不会旋转。

在每个视图控制器中执行此操作

if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        NSLog(@"Landscape left detected!");
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"Landscape right detected!");
        return YES;
}

首先,你不必为每个方向都写支票。只需在viewController的shouldAutorotateToInterfaceOrientation方法中使用以下代码即可实现这一点

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
}

第二,您可以提供更多关于如何实际添加更多视图的详细信息。找到问题会更有帮助。

Hi,我能知道将方向代码编写为return(interface-orientation==ui-interface-orientationlandscaperight)的区别吗;这两种代码的工作原理完全相同,但主要区别在于,您可以在一行代码中完成所有这些,就像您在多个if语句中尝试完成的一样。
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);