くまちゃんのiOS/Androidゲームプログラミング

マイペースでゲームつくってます。

画面を横に

iOS6で変更があり、shouldAutorotateToInterfaceOrientationは使わない仕様変更。

よって、3段階の処理が必要。

1.  SummaryのSupported Interface Orientations

Landscape LeftとLandscape Rightを選択(黒くする!)

 

2. AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

 // -略-

 self.window.rootViewController = _viewCtrl;

 

 // -略-

}

 

3. ViewController.m

- (BOOL)shouldAutorotate {

    returnYES;

}

 

- (NSUInteger)supportedInterfaceOrientations {

    returnUIInterfaceOrientationMaskLandscape;

}

iOS5以前は

 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation==UIInterfaceOrientationLandscapeRight||

            interfaceOrientation==UIInterfaceOrientationLandscapeLeft);

}

 

両方書いておくとiOS6iOS5同時対応とのことです。