xcode 画面の向きを変更する
TRANSCRIPT
Xcode上で"Info.plist"ファイルを開く
ファイルを開いたら"Bundle version"を右クリック。
ポップアップメニューから"Add Row"を選ぶ。
Keyの選択で、"Initial interface"を選ぶ。
Valueを選択する。
"info.plist"を書き換える方法以外に、プログラム記述によっても画面の向きを変更することが出来ます。"ViewController.m"ファイルを開いて、loadViewメソッドの先頭に以下の1行を追加してください。
[OrientationSampleViewController.mファイル内の、loadViewメソッド]
- (void) loadView{ //画面を横向きにする [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandsapeRight];
(以下略)}
UIApplicationクラスのsetStatusBarOrientationインスタンスメソッドの引数に、画面の向きを表すUllnterfaceOrientasionLandsapeRight、つまりホームボタンが右側にくるような横向きの画面を指定しています。
画面の向きには以下の4つの定数を指定することができます。
定数 説明UIInterfaceOrientationPortrait Portrait(botton home button)と同一。
ホームボタが下に来る様な縦向きの画面。UIInterfaceOrientationPortraitUpsideDown Portrait(top home button)と同一。
ホームボタンが上に来るような縦向きの画面。UIInterfaceOrientationLandscapeLeft Landscape(left home button)と同一。
ホームボタンが左に来るような横向きの画面。UIInterfaceOrientationLandscapeRight Landscape(right home button)と同一。
ホームボタンが右に来るような横向きの画面。