Cocos2d iphone Cocos2d iphone 2.0为横向设置了自动旋转,但首次加载时视图位置错误

Cocos2d iphone Cocos2d iphone 2.0为横向设置了自动旋转,但首次加载时视图位置错误,cocos2d-iphone,landscape,autorotate,Cocos2d Iphone,Landscape,Autorotate,该应用程序仅为横向设置 在Project->target->Summary->Supported Interface Orientations中,我启用了两个横向图标(左侧和右侧) 在AppDelegate.m中,编写了以下代码: - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLa

该应用程序仅为横向设置

在Project->target->Summary->Supported Interface Orientations中,我启用了两个横向图标(左侧和右侧)

在AppDelegate.m中,编写了以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
      return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
当应用程序在设备上运行时,在默认cocos2d图标后开始显示的视图,所有位置都是错误的,都移动到了右下方。当我旋转屏幕时,一切正常,都在正确的位置

怎么了

我还尝试了以下方法: 我禁用了Project->target->Summary->Supported Interface Orientations中的所有图标。 AppDelegate中的代码仍在使用中。 然后,最开始的视图是正常的,但屏幕可以旋转到protrait


任何人都可以帮忙吗?

还可以在AppDelegate中将这两个用于iOS6定向

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;
}

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskLandscape;
}

谢谢您的回答。我尝试添加这两种方法。肖像不见了。但第一次加载的视图缺少右侧部分,仅显示左侧2/3部分。视图的位置是确定的。在阅读了上面的答案之后,我尝试将init函数放入第一个视图的onEnter方法中。从日志中,我可以看到在init之后启动了onEnter,但问题仍然存在。是否手动添加了新视图?在应用程序didFinishLaunchingWithOptions中发布代码:[SceneManager goMenu];在SceneManager.m:+(void)goMenu{CCLayer*layer=[MenuLayer node];[SceneManager go:layer];}+(void)go:(CCLayer*)layer{CCDirector*director=[CCDirector sharedDirector];CCScene*newScene=[SceneManager wrap:layer];if([director runningScene]){[director replacescence:newScene];}else{[director runWithScene:newScene];}