xcode 画面の向きを変更する

4

Click here to load reader

Upload: nickyu

Post on 28-Jul-2015

923 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Xcode 画面の向きを変更する

Xcode上で"Info.plist"ファイルを開く

ファイルを開いたら"Bundle version"を右クリック。

Page 2: Xcode 画面の向きを変更する

ポップアップメニューから"Add Row"を選ぶ。

Keyの選択で、"Initial interface"を選ぶ。

Page 3: Xcode 画面の向きを変更する

Valueを選択する。

Page 4: Xcode 画面の向きを変更する

"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)と同一。

ホームボタンが右に来るような横向きの画面。