iPhoneアプリのViewの向きを指定してプログラムを起動する | 小さいリンゴの物語

小さいリンゴの物語

リンゴの小さいタイプ、iPhone,iPadについて書きたいなと。

特に自作アプリについて開発中に思ったことなどを書いていきたいな~。

自作アプリの宣伝や使い方の説明なんかもしま~す。

これから末永くよろしくお願いします。



Viewの向きを指定して起動する方法はiScoreboardで使用したのですが




まず、Info.plistに以下のようにKeyを追加して




  Key : Initial interface orientation

 Value : Portrait (bottom home button)

     Portrait (top home button)

     Landscape (left home button)

     Landscape (right home button)
 




更にOSのバージョンが2.1.1以前の時は次のコードを書きます。




 Info.plistに以下の記述を追加する




 Key : UIInterfaceOrientation

 Value : UIInterfaceOrientationLandscapeLeft(左側にホームボタン)

  又は UIInterfaceOrientationLandscapeRight(右側にホームボタン)




そしてiPhoneを強制的に横向き状態にするため次のコードを追加します。




viewDidLoadに追加しておけばいいと思うよ。




 左向き(右側にホームボタン)

 [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];




 右向き(左側にホームボタン)

 [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];