UIView は回転を処理しませんが、UIViewController は処理します。したがって、必要なのは UIViewController を作成することだけです。これは shouldAutorotateToInterfaceOrientation を実装し、このコントローラーを rootViewController として UIWindow に設定します。
そんな感じ:
UIViewController * vc = [[[MyViewController alloc] init] autorelease];
vc.view.frame = [[UIScreen mainScreen] bounds];
vc.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
//you vc.view initialization here
UIWindow * window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.windowLevel = UIWindowLevelStatusBar;
window.backgroundColor = [UIColor clearColor];
[window setRootViewController:vc];
[window makeKeyAndVisible];
そして、このMyViewControllerを使用しました。メインアプリケーションの変更を反映させたいからです
@interface MyViewController : UIViewController
@end
@implementation MyViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
UIWindow *window = ((UIWindow *)[[UIApplication sharedApplication].windows objectAtIndex:0]);
UIViewController *controller = window.rootViewController;
if (!controller) {
NSLog(@"%@", @"I would like to get rootViewController of main window");
return YES;
}
return [controller shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
}
@end
ただし、必要に応じて、いつでも YES を返すか、ロジックを記述することができます。