Cocos 2d 2.0 shouldAutorotate不工作? [英] Cocos 2d 2.0 shouldAutorotate not working?

查看:185
本文介绍了Cocos 2d 2.0 shouldAutorotate不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些问题。我有一个cocos2d游戏,我只是做了开发。但我遇到了一个问题,我需要在我的应用程序plist启用纵向方向,游戏中心登录工作,而不会引发SIGABRT错误。所以,一旦我从我的应用程序的构建摘要页面(或将其添加到info.plist文件作为支持的方向)启用它工作正常。但是,然后任何时候在我的游戏,如果你打开iPhone,它会翻转到纵向模式,如果它感觉到你这样的方式。我试图搞砸从我的AppDelegate.m的shouldAutorotateToInterfaceOrientation方法,它没有得到调用全部,不是在任何时候是它被调用。我在方法中抛出一个NSLog语句,以确保它是否被调用,而不是。

I'm having some issues. I have a cocos2d game I'm just about done developing. However I've run into a problem where I need to enable portrait orientation in my apps plist for game center sign in to work without throwing a SIGABRT error. So once I enable that from my app's build summary page (Or add it to the info.plist file as a supported orientation) it works fine. But then anytime in my game if you turn the iPhone it will flip to portrait mode if it senses you turned it that way. I've tried messing with the shouldAutorotateToInterfaceOrientation method from my AppDelegate.m and it's not getting called AT ALL, not at any time is it being called. I threw an NSLog statement in the method to be sure if it's being called, and it's not.

所以,基本上我的真正的问题是。我需要我的游戏停留在横向模式BESIDES当游戏中心登录屏幕弹出。

So, basically my real issue is. I need my game to STAY in landscape mode BESIDES when the Game Center login screen pops up. How do I do this in a Cocos2d 2.0 game?

我正在使用iOS6

推荐答案

首先,确保应用程序在目标摘要中支持纵向和横向方向。

First, make sure that the app supports portrait and landscape orientations in the target summary.

然后,您需要创建一个新的根视图控制器,强制您进入横向模式,以使您的游戏不会奇怪地旋转:

Then you'll need to make a new root view controller that forces you into landscape mode so that your game doesn't start rotating strangely:

@implementation CUSTOM_RootViewController
-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate {
    return YES;
}

@end

最后,在AppDelegate。 m文件,用您的新导航控制器替换原来的导航控制器:

Finally, in the AppDelegate.m file, replace the original navigation controller with your new one:

// Create a Navigation Controller with the Director
//navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
navController_ = [[SMD_RootViewController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;

现在你应该能够在顶部覆盖一个纵向视图。

Now you should be able to overlay a portrait view on top.

希望这有助于!

这篇关于Cocos 2d 2.0 shouldAutorotate不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆