iOS 6 で、画面回転のメソッドが変わった

iOS 6 から、画面回転で shouldAutorotateToInterfaceOrientation が呼ばれなくなってる。
代わりに、shouldAutorotate が呼ばれることになってる。
その他、UINavigationController は、画面回転に沿ったカスタマイズを用意しなければならない。


------------- CustomNavigationController.h -------------------
#import <Foundation/Foundation.h>

@interface CustomNavigationController : UINavigationController<UINavigationControllerDelegate>
{
}
 
/*!
 @abstract iOS6 以降、画面向きのサポート対象
 */

-(NSUInteger)supportedInterfaceOrientations;
 
/*!
 @abstract iOS6 以降、画面回転の許可
 @return YES = 画面回転を許可する
 */

-(BOOL)shouldAutorotate;
 
/*!
 @abstract iOS6 以降、起動時の画面の向き
 */

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
 
@end
 
------------- CustomNavigationController.m -------------------
#import "CustomNavigationController.h"
 
@implementation CustomNavigationController
 
-(NSUInteger)supportedInterfaceOrientations
{
    returnself.topViewController.supportedInterfaceOrientations;
}
 
-(BOOL)shouldAutorotate
{
    returnself.topViewController.shouldAutorotate;
}
 
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    returnself.topViewController.preferredInterfaceOrientationForPresentation;
}
 
@end


====================================
AppDelegate.h の中、、

#import <UIKit/UIKit.h>
#import <sys/types.h>
#import <sys/stat.h>
#import <fts.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
 
@property (strong, nonatomic) UIWindow *window;

@property ( nonatomic, retain ) UINavigationController* navigationController;
 
@end
=====================================
AppDelegate.m の中、、

#pragma mark アプリケーション起動時の処理
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    // iOS 5.x まで使用していた UINavigationController を廃止
    //navigationController = [ [UINavigationController alloc] initWithRootViewController: webViewController ];
    // iOS 5.x まで addSubview を実行していたのを廃止
    //[ self.window addSubview: navigationController.view ];


    navigationController = [ [CustomNavigationControlleralloc] initWithRootViewController: webViewController];
    [self.windowsetRootViewController: navigationController];



各ビューコントローラで、

#pragma mark ----- for  iOS 5.x まで -----------
- (BOOL)shouldAutorotateToInterfaceOrientation: ( UIInterfaceOrientation ) interfaceOrientation
{
    returnYES;
}
#pragma mark ----- for iOS 6      --------------
// 画面回転の許可
-(BOOL)shouldAutorotate
{
    returnYES;
}
// 画面回転方向 サポート
-(NSUInteger)supportedInterfaceOrientations
{
    returnUIInterfaceOrientationMaskAll;
}

// 初期表示の画面向き
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    returnUIInterfaceOrientationPortrait;
}