この他のアプローチを見てください:
http://www.sebastianborgrewe.de/only-make-one-single-view-controller-rotate/
回転を許可するには、ViewController に canRotate を実装するだけです。
iOS 7 で問題なく動作します。
2015-01-30
sebastian のサイトが動作していないようです (404 エラー) ため、これはその解決策の私の解釈です:
セバスチャンとは異なり、私はプロトコル (C# のインターフェイスなど) を使用して、各ビュー コントローラーで「-(void)canrotate:」メソッドを作成しないようにしています。
IRotationCapabilities.h
-----------------------
#ifndef NICE_APPS_IRotationCapabilities_h
#define NICE_APPS_IRotationCapabilities_h
@protocol IRotationCapabilities < NSObject >
// Empty protocol
@end
#endif
FirstViewController.h
---------------------
- ( void )viewWillAppear:( BOOL )animated
{
[ super viewWillAppear:animated ];
// Forces the portrait orientation, if needed
if( ![ self conformsToProtocol:@protocol( IRotationCapabilities ) ] )
{
if( self.navigationController.interfaceOrientation != UIInterfaceOrientationPortrait )
{
[ [ UIDevice currentDevice ] setValue:@( 1 ) forKey:@"orientation" ];
}
}
}
SecondViewController.h
-----------------------
#import "IRotationCapabilities.h"
@interface SecondViewController : UIViewController < IRotationCapabilities >
AppDelegate.m
-------------
#pragma mark - Orientation management
- ( NSUInteger )application:( UIApplication * )application supportedInterfaceOrientationsForWindow:( UIWindow * )window
{
if( __iPhone )
{
// Gets topmost/visible view controller
UIViewController * currentViewController = [ self topViewController ];
// Checks whether it implements rotation
if( [ currentViewController conformsToProtocol:@protocol( IRotationCapabilities ) ] )
{
// Unlock landscape view orientations for this view controller
return ( UIInterfaceOrientationMaskAllButUpsideDown );
}
// Allows only portrait orientation (standard behavior)
return ( UIInterfaceOrientationMaskPortrait );
}
else
{
// Unlock landscape view orientations for iPad
return ( UIInterfaceOrientationMaskAll );
}
}