我正在将Everyplay集成到我的Cocos2d Game.My游戏中,只支持横向。在iPad上一切都很顺利。但是当我在iPhone(iOS6)上测试时,当我调用"[Everyplay sharedInstance showEveryplay]“时抛出异常如下:原因:‘支持的方向与应用程序没有共同的方向,shouldAutorotate返回YES’
我知道定向机制在iOS6中发生了变化,所以我添加了这个方法:
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskAllButUpsideDown;
}然后"[Everyplay sharedInstance showEveryplay]“无一例外地工作,但我的游戏也支持我不想要的肖像定向。
如果我只想在我的游戏中支持景观,但让"[Everyplay sharedInstance showEveryplay]“无一例外地工作,我该怎么办?
发布于 2013-08-13 14:06:11
您有两个选项来解决这个问题。
选项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;
}发布于 2013-05-13 18:40:18
在iPhone上,Everyplay webview总是处于纵向模式,但在iPad上,webview支持这两种模式。录制支持这两种模式,视频播放器也是如此。我们可能会在不久的将来更新景观模式的iPhone分辨率,但它将需要一些重新设计,才能完成这项任务。
https://stackoverflow.com/questions/16370261
复制相似问题