2

ゲームセンターを使ってIOS5のアプリを開発しました。コードを IOS 6 で実行したいので、ゲーム センターのログイン画面が表示されたときにアプリケーションがクラッシュしないように、横向きと縦向きの両方の向きをアプリケーションでサポートできるようにしました。しかし、その後、私のホームビューコントローラーは横向きで起動しません。代わりに、別のビューに移動すると横向きで開き、戻ってくるとホーム ビューが横向きで開きます。ただし、ホーム ビューは初めてランドスケープ モードで開きません。

コードは次のとおりです。

- (BOOL)shouldAutorotate
{
  return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}

これらは、IOS 6 のホーム ビューで使用するデリゲートです。

4

1 に答える 1

5

このメソッドをアプリ デリゲートに追加して、IOS 6 の目的の向きをサポートします。

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{
   if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else  /* iphone */
        return UIInterfaceOrientationMaskAllButUpsideDown;
}

これらのデリゲートは、IOS 6 の残りのクラスでオリエンテーションに使用します。

- (BOOL)shouldAutorotate
{

return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
  return UIInterfaceOrientationLandscapeLeft;
}
于 2012-10-16T05:26:08.413 に答える