Cocos2d iphone 如何使应用程序在CoCoS2D2.0中处于横向

Cocos2d iphone 如何使应用程序在CoCoS2D2.0中处于横向,cocos2d-iphone,orientation,xcode4.3,uiinterfaceorientation,Cocos2d Iphone,Orientation,Xcode4.3,Uiinterfaceorientation,(很抱歉,我不能包含图像。我没有足够高的代表,所以我只提供了图像的链接) 正如标题所说,我的应用程序在横向模式下有问题。我希望整个应用程序处于横向模式,因此我在目标摘要中只选择了横向左侧和横向右侧。我还说: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLands

(很抱歉,我不能包含图像。我没有足够高的代表,所以我只提供了图像的链接)

正如标题所说,我的应用程序在横向模式下有问题。我希望整个应用程序处于横向模式,因此我在目标摘要中只选择了横向左侧和横向右侧。我还说:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
在我的AppDelegate.m中。我还访问了我的info.plist并将“初始界面方向设置为横向(左主按钮)。但是我在模拟器和实际设备上的方向是错误的。下面是我在故事板中的图片(我希望它看起来像什么)

但这就是我的模拟器和设备上的样子


有人知道如何解决这个问题吗?谢谢

编辑:如果您正在运行Cocos2d 2.0 rc1或rc0a,那么
应该将AutorotateTointerFaceOrientation:
方法放置在RootViewController.m文件中。如果您正在运行CoCoCoS2D 2.0,那么
应该将AutorotateTointerFaceOrientation:
放置在n AppDelegate.m文件

如果您使用Cocos2d 2.0 rc1或rc0a中的某个模板创建应用程序,则该方法将已位于RootViewController.m中

如果使用Coco2d 2.0,则该方法将已在AppDelegate.m中

只需编辑该方法,即可返回所需的方向

根据您使用的Cocos2d 2.0版本,编辑RootViewController.m或AppDelegate.m类中的方法,使其看起来像这样以适应两种横向方向:

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

我没有RootViewController。m我有AppDelegate、IntroLayer、MainMenu(UIViewController的子类)、CCViewController(用于我的cocos游戏)、cocos2dViewController(CCViewController的子类)和GamePlay(游戏的所有内容都在这里)。如果您使用随附的Cocos2d 2.0模板之一制作应用程序,则您将拥有一个RootViewController.m类。但如果您没有,则应用程序应具有的任何主ViewController都将是添加该代码的主ViewController。在AppDelegate中,应用程序主/主视图控制器就是视图控制器将您的glView添加到,然后将相同的视图控制器添加到应用程序主UI窗口。可能是您的AppDelegate没有正确设置Cocos2d以使用viewController,但Apple建议您使用一个。我的应用程序确实使用了Cocos2d 2.0模板,但它仅从AppDelegate、HelloWorldLayer、一个d IntroLayerSorry,我刚刚注意到,在Coco2d 2.0 rc1中,正如我所描述的那样,但是在Cocos2d 2.0中,RootViewController类被删除,取而代之的是CCDirector是CC_VIEWCONTROLLER的一个子类,而在ios上,CC_VIEWCONTROLLER被定义为UIViewController。director确实将AppDelegate设置为VIEWCONTROLLER委托,因此,您在AppDelegate中放置shouldAutorotateToInterfaceOrientation:的方法是正确的。您是否有一个包含Cocos2d内容的Cocos2d场景,可以运行以查看该场景是否正确旋转到横向?我猜您的问题与您在横向中使用情节提要定义主菜单视图控制器有关。