Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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_Xcode_Orientation - Fatal编程技术网

iPhone游戏横向定位问题

iPhone游戏横向定位问题,iphone,objective-c,xcode,orientation,Iphone,Objective C,Xcode,Orientation,我正在尝试制作一个简单的iPhone游戏,我需要游戏处于横向模式。我可以将初始视图设置为横向视图,但如果删除初始视图并将其替换为新视图(从主菜单转到游戏屏幕),则新视图现在处于纵向模式。此外,如果我切换回第一个视图(移除游戏屏幕,然后创建新的菜单视图),则视图仍处于纵向模式。我已正确设置Info.plist文件以使用横向权限初始化,并已使用以下代码设置GameViewController.m文件: -(BOOL) shouldAutorotateToInterfaceOrientation:

我正在尝试制作一个简单的iPhone游戏,我需要游戏处于横向模式。我可以将初始视图设置为横向视图,但如果删除初始视图并将其替换为新视图(从主菜单转到游戏屏幕),则新视图现在处于纵向模式。此外,如果我切换回第一个视图(移除游戏屏幕,然后创建新的菜单视图),则视图仍处于纵向模式。我已正确设置Info.plist文件以使用横向权限初始化,并已使用以下代码设置GameViewController.m文件:

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

我读过很多关于人们在设置横向方向时遇到问题的帖子,但它们似乎总是关于应用程序的初始负载(只显示一个视图)。我似乎找不到解决这个问题的办法。有人能帮我吗?

确保屏幕上可见的所有视图控制器都支持横向。我建议,在您的shouldAutorotateToInterfaceOrientation中,返回UIInterfaceOrientationiSis景观(interfaceOrientation);而不是你的代码。这将确保两种横向定位都有效。你能再分享一下你是如何从主菜单切换到游戏屏幕的吗?

你无意中发现了

平台上最著名的bug之一! 恭喜你发现了它!在这里:

请务必阅读开头的一段:“这是一个重要的提示,提醒我们手头还有一个众所周知的问题……”


它为您提供了所有应用程序都使用的解决方案。

您的两个视图是否都有shouldAutorotatePointerFaceOrientation:setup以返回UIInterfaceOrientationAndscapeRight的YES?当我触摸屏幕时,会调用此函数,触摸两次后,它会切换到下一个视图-(void)touchesend:(NSSet*)touchs with event:(UIEvent*)event{UITouch*touch=[touch anyObject];NSUInteger numTaps=[touch tapCount];if(numTaps>1){[mpmanagerdostatechange:[gsMain class]];}}感谢您提供的链接,我将仔细查看。