2009年7月15日水曜日

[iPhone] View Orientation

iPhoneは横にすると、自動的に画面を横表示に切り替えられる。
今日は、縦や横の切り替えを試してみた。

1. Xcodeの起動

2. 新規プロジェクトの作成
 ファイル > 新規プロジェクト...
 View-based Applicationを選択

3. UIの作成
 View上にLabelを配置
 配置したLabelを選択し、Tools > Size Inspector を開く
 Placementで中央にLabelを配置し、
 Autosizingで何も選択しないようにすると、
 自動で中央に位置を合わせてくれる

4. ソースコードの編集
 ViewOrientationViewController.mを開く
 (この場合、ViewOrientationがプロジェクト名)
 shoudAutorotateToInterfaceOrientationのコメントを外し、
 YESを返すように編集

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

 // Return YES for supported orientations

 // return (interfaceOrientation == UIInterfaceOrientationPortrait);

   return YES;

 }


5. ビルドと実行
 ビルドと実行するとiPhone Simulatorが立ち上がる

 iPhone Simulatorの向きを変えるには、command + 矢印 (右、左)で切り替え



0 件のコメント:

コメントを投稿