はい、appDelegate に次のメソッドを配置することで、特定の viewController をランドスケープとして作成できます。
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.restrictRotation)
return UIInterfaceOrientationMaskPortrait;
else
return UIInterfaceOrientationMaskAll;
}
次に、appDelegate で bool プロパティを 1 つ取得します
@property (nonatomic) BOOL restrictRotation;
次に、向きを変更したいView ControllerでappDelegate共有インスタンスを作成し、以下の方法のように制限を変更できるようにします
-(void) restrictRotation:(BOOL) restriction
{
AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
appDelegate.restrictRotation = restriction;
}
ビューコントローラーからこのメソッドを呼び出して、必要に応じて向きを変更してください。
[self restrictRotation:NO];
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
最も重要なことは、ビューが消えるときに向きを縦向きに変更することです。そうしないと、他のすべてのviewControllerも横向きモードになります。
-(void)viewWillDisappear:(BOOL)animated
{
NSNumber *value = [NSNumber numberWithInt:UIDeviceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
[self restrictRotation:YES];
}
これがお役に立てば幸いです。