2013-05-04 52 views
2

我将Everyplay与我的Cocos2d Game.My游戏整合,只支持横向导向。 在iPad上一切顺利。 但是当我在iPhone(iOS6)上测试时,当我打电话给“[[Everyplay sharedInstance] showEveryplay]”时,它会抛出异常:“ 原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'Everyplay是否支持iOS6中的横向?

我知道方位机制iOS6.So改变了我加入这个方法:

-(BOOL)shouldAutorotate{ 
    return YES; 
} 
-(NSUInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 
     return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

然后“[Everyplay sharedInstance] showEveryplay]”的作品无一例外,但我的游戏还支持纵向方向,我不希望至。

如果我只想支持我的游戏中的横向,但是让[“[Everyplay sharedInstance] showEveryplay]”毫无例外地工作,我该怎么办?

回答

0

在iPhone上Everyplay webview始终处于肖像模式,但在iPad上,webview支持这两种模式。录制支持两种模式,就像视频播放器一样。我们很可能在不久的将来更新iPhone分辨率的横向模式,但在完成此任务之前需要重新设计。

2

你有两个选择如何解决这个问题。

选项1:

添加UISupportedInterfaceOrientations阵列到游戏的Info.plist与项目UIInterfaceOrientationPortrait,UIInterfaceOrientationLandscapeLeft,UIInterfaceOrientationLandscapeRight和UIInterfaceOrientationPortraitUpsideDown。您可以通过从项目摘要页面中检查所有支持的界面方向或手动编辑info.plist文件,轻松地从xCode执行此操作。

选项2:

添加以下方法到应用程序的AppDelegate.m文件:

// IOS 6 

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

在这两种情况下,你还必须确保你已经添加了景观仅取向处理代码到您的游戏的主要UIViewController。

// IOS 5 

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

// IOS 6 

- (BOOL)shouldAutorotate { 
    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; 
} 
+0

选项2最适合我,谢谢 – user3610913 2014-06-25 09:57:25