【问题标题】:Does Everyplay support Landscape in iOS6?Everyplay 在 iOS6 中是否支持横向?
【发布时间】:2013-05-04 03:23:19
【问题描述】:

我正在将 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]”毫无例外地工作,但我的游戏也支持我不想的纵向。

如果我只想在My Game中支持Landscape,却让“[[Everyplay sharedInstance] showEveryplay]”无异常工作,该怎么办?

【问题讨论】:

    标签: ios6 landscape everyplay


    【解决方案1】:

    您有两种解决问题的方法。

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

    【讨论】:

    • 选项 2 最适合我,谢谢
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      • 2012-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多