iOS6中Everyplay支持横屏吗?



我将Everyplay整合到我的Cocos2d游戏中。我的游戏只支持横向。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]"毫无例外地工作,我该怎么办?

您有两种方法来解决这个问题。

选项1:

添加uissupportedinterfaceorientations数组到你的游戏的信息。带有项目UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight和UIInterfaceOrientationPortrait upsidedown的列表。在xCode中,你可以通过检查项目摘要页面中所有支持的界面方向或编辑信息来轻松地做到这一点。手动Plist文件

选项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;
}

iPhone上的Everyplay webview总是在纵向模式,但在iPad上的webview支持两种模式。录音和视频播放器都支持这两种模式。我们可能会在不久的将来为iPhone的分辨率更新横向模式,但在此任务完成之前,它将需要一些重新设计。

最新更新