3

我知道这个主题已经启动了很多线程,但没有一个能解决这个问题。我一直在用使用 cocos2d v1.1.0-beta2b 的 kobold2d 创建一个游戏,自从我升级到 xcode 4.5 和 ios 6 之后,所有的方向都被抛弃了。通常 cocos2d 应用程序将以横向模式启动,但现在随着更新它以纵向模式启动并导致图层上的所有对象反转,但不知何故这已经修复了。所以现在我的项目在模拟器和 ios 设备上都以横向模式启动,但屏幕上的所有内容仍处于纵向模式。在我更新到最新软件之前,一切都运行良好。我能做些什么来解决这个问题?

所以我决定用旧的 xcode 4.4.1 构建我的项目,看看控制台中的输出与新的 xcode 4.5 有什么不同,这就是我发现的:

xcode 4.5 的输出

2012-09-21 14:50:54.558 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: OS version: 6.0 (0x06000000)
2012-09-21 14:50:54.560 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_VENDOR:   Apple Computer, Inc.
2012-09-21 14:50:54.560 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_RENDERER: Apple Software Renderer
2012-09-21 14:50:54.560 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_VERSION:  OpenGL ES-CM 1.1 APPLE
2012-09-21 14:50:54.561 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-09-21 14:50:54.561 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-09-21 14:50:54.562 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL_MAX_SAMPLES: 4
2012-09-21 14:50:54.562 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL supports PVRTC: YES
2012-09-21 14:50:54.563 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL supports BGRA8888 textures: YES
2012-09-21 14:50:54.563 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL supports NPOT textures: YES
2012-09-21 14:50:54.563 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: GL supports discard_framebuffer: YES
2012-09-21 14:50:54.564 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: compiled with NPOT support: NO
2012-09-21 14:50:54.564 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: compiled with VBO support in TextureAtlas : YES
2012-09-21 14:50:54.564 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-09-21 14:50:54.565 KTireHoops-iOS[4539:c07] -[CCConfiguration init] : cocos2d: compiled with Profiling Support: NO
2012-09-21 14:50:54.565 KTireHoops-iOS[4539:c07] -[CCDirector init] : cocos2d: cocos2d v1.1.0-beta2b
2012-09-21 14:50:54.566 KTireHoops-iOS[4539:c07] -[CCDirector init] : cocos2d: Using Director Type:CCDirectorDisplayLink
2012-09-21 14:50:54.566 KTireHoops-iOS[4539:c07] -[KKAppDelegate applicationDidFinishLaunching:] : Kobold2D™ v1.1.2
2012-09-21 14:50:54.571 KTireHoops-iOS[4539:c07] Retina Display enabled: YES
2012-09-21 14:50:54.573 KTireHoops-iOS[4539:c07] -[ES1Renderer resizeFromLayer:] : cocos2d: surface size: 480x320
2012-09-21 14:50:54.579 KTireHoops-iOS[4539:c07] -[AppDelegate initializationComplete] : ARC is either not available or not enabled
2012-09-21 14:50:54.609 KTireHoops-iOS[4539:c07] -[CCDirectorDisplayLink startAnimation] : startAnimation
2012-09-21 14:50:54.610 KTireHoops-iOS[4539:c07] -[CCDirectorDisplayLink startAnimation] : cocos2d: Frame interval: 1

xcode 4.4.1 的输出

2012-09-21 14:52:01.343 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: OS version: 5.1 (0x05010000)
2012-09-21 14:52:01.345 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_VENDOR:   Apple Computer, Inc.
2012-09-21 14:52:01.345 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_RENDERER: Apple Software Renderer
2012-09-21 14:52:01.346 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_VERSION:  OpenGL ES-CM 1.1 APPLE
2012-09-21 14:52:01.346 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-09-21 14:52:01.347 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-09-21 14:52:01.347 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL_MAX_SAMPLES: 4
2012-09-21 14:52:01.347 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL supports PVRTC: YES
2012-09-21 14:52:01.348 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL supports BGRA8888 textures: YES
2012-09-21 14:52:01.348 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL supports NPOT textures: YES
2012-09-21 14:52:01.350 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: GL supports discard_framebuffer: YES
2012-09-21 14:52:01.350 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: compiled with NPOT support: NO
2012-09-21 14:52:01.351 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: compiled with VBO support in TextureAtlas : YES
2012-09-21 14:52:01.351 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-09-21 14:52:01.351 KTireHoops-iOS[5207:c07] -[CCConfiguration init] : cocos2d: compiled with Profiling Support: NO
2012-09-21 14:52:01.352 KTireHoops-iOS[5207:c07] -[CCDirector init] : cocos2d: cocos2d v1.1.0-beta2b
2012-09-21 14:52:01.352 KTireHoops-iOS[5207:c07] -[CCDirector init] : cocos2d: Using Director Type:CCDirectorDisplayLink
2012-09-21 14:52:01.353 KTireHoops-iOS[5207:c07] -[KKAppDelegate applicationDidFinishLaunching:] : Kobold2D™ v1.1.2
2012-09-21 14:52:01.360 KTireHoops-iOS[5207:c07] Retina Display enabled: YES
2012-09-21 14:52:01.361 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.361 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.362 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.362 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.362 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.363 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.396 KTireHoops-iOS[5207:c07] -[AppDelegate initializationComplete] : ARC is either not available or not enabled
2012-09-21 14:52:01.436 KTireHoops-iOS[5207:c07] -[CCDirectorDisplayLink startAnimation] : startAnimation
2012-09-21 14:52:01.437 KTireHoops-iOS[5207:c07] -[CCDirectorDisplayLink startAnimation] : cocos2d: Frame interval: 1
2012-09-21 14:52:01.438 KTireHoops-iOS[5207:c07] -[KKRootViewController shouldAutorotateToInterfaceOrientation:] : shouldAutorotateToInterfaceOrientation
2012-09-21 14:52:01.439 KTireHoops-iOS[5207:c07] -[ES1Renderer resizeFromLayer:] : cocos2d: surface size: 320x480

从我所见, (shouldAutorotateToInterfaceOrientation) 方法不再在带有 ios 6 的新 xcode 中被调用。这导致了奇怪的方向错误。有谁知道解决这个问题。

4

3 回答 3

13

这是快速修复:

  • AppDelegate.mm文件中替换 该行

    [window_ addSubview:navController_.view];  
    

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0){
        [window_ setRootViewController:navController_];
    }
    else{
        [window_ addSubview:navController_.view];
    }
    
  • 在AppDelegate.mm中添加以下方法

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
          return UIInterfaceOrientationMaskLandscape;
      }
    
于 2012-12-11T09:20:06.777 回答
1

发生这种情况是因为 Apple 改变了管理 UIViewController 的方向的方式。在 iOS6 中,Oreintation 处理方式不同。在 iOS6 中容器(例如 UINavigationController)不会咨询它们的子级来确定它们是否应该自动旋转。默认情况下,应用程序和视图控制器支持的界面方向设置为 iPad 惯用语的 UIInterfaceOrientationMaskAll 和 iPhone 惯用语的 UIInterfaceOrientationMaskAllButUpsideDown 。因此,设备在默认情况下会更改方向。

于 2013-11-04T06:37:28.620 回答
0

http://www.cocos2d-iphone.org/forum/topic/33326

[编辑] 上面的链接不再起作用。原因可能是 cocos2d-iphone 小组修复了这个错误或其他问题。

对于那些仍然有同样问题的人,更好的方法可能是谷歌

cocos2d iphone ios6 orientation bug

于 2012-09-21T01:32:16.903 回答