0

cocos2d でゲームを開発しましたが、すべてのゲーム画面はランドスケープ モードです。Game Center を実装しようとしていますが、認証時にクラッシュします。同様のタイプの問題の回答が見つかりませんでした。正しいアプローチを提案してください...

クラッシュの問題:-「UIApplicationInvalidInterfaceOrientation」、理由:「サポートされている方向にはアプリケーションと共通の方向がなく、shouldAutorotate は YES を返しています」

以下の解決策を試しましたが、ゲームの向きも乱れ、ゲームはポートレートモードでも動作します。これは望ましくありません:-

  • (NSUInteger)アプリケーション:(UIApplication*)アプリケーション

    supportedInterfaceOrientationsForWindow: (UIWindow*)window { return UIInterfaceOrientationMaskAllButUpsideDown; }

4

2 に答える 2

2

Xcode の概要ページで横向きを選択したことを確認してください。

ここに画像の説明を入力

また、これらのコードをビューコントローラーに追加します

-(NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskLandscape;
}

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

AppDelegate でこの関数を更新します。

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskLandscape;
}
于 2013-07-23T05:35:12.073 に答える
0

その解決策は短いです、私はそれを見つける前に多くの時間を費やしました:

AppDelegateメソッド内に次のdidFinishLaunchingWithOptions行を入れます。

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

明らかに、ログイン ゲーム センター メソッドを呼び出す前に、UIWindows

于 2013-07-25T05:21:22.367 に答える