IOS6になってrotateがおかしいメモ

今まではLeft固定で問題なく起動できていたのだけど、Xcode4.5でiPhone5やiPadで起動してみると本体は横向きなんだけど中身が縦表示になっている。IOS6で回転の仕組みが変更になったようです。具体的にはshouldAutorotateToInterfaceOrientationがDeprecatedで、supportedInterfaceOrientationsとshouldAutorotateが追加されています。

  • before
    - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
    	return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
  • after
    -(NSUInteger)supportedInterfaceOrientations{
    	return UIInterfaceOrientationMaskLandscapeLeft;
    }
    - (BOOL)shouldAutorotate{
    	return YES;
    }

ついでに僕の環境だとこれだけだと解決できず、具体的にはshouldAutorotateもsupportedInterfaceOrientationsも呼ばれませんでしたが別の原因がありました。これは結構前の変更分みたいですね。今まで奇跡的に動いていた感じでした。こんなログ今まで出てたっけなぁ。

Applications are expected to have a root view controller at the end of application launch
  • before
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    	[window addSubview:controller.view];
    	....
    	return YES;
    }
  • after
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    	[self.window setRootViewController:controller];
    	....
    	return YES;
    }


[ 編集 | 凍結 | 差分 | 添付 | 複製 | 名前変更 | リロード ]   [ 新規 | 一覧 | 単語検索 | 最終更新 | ヘルプ ]
Last-modified: 2012-10-02 (火) 05:31:16 (4556d)