iOS6中的横向模式在应用程序的中间

我正在使用iOS6设备xcode 4.5和山狮子mac。 在我的应用程序开始在肖像模式(3屏幕)。 但是第四屏幕应该是横向的,并且应该支持横向左侧和横向右侧。

大部分解释都显示如何旋转。

在appddelegate使用

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; navigationController.navigationBar.tintColor = [UIColor blackColor]; // Set RootViewController to window if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) { // warning: addSubView doesn't work on iOS6 [self.window addSubview: navigationController.view]; } else { // use this mehod on ios6 [self.window setRootViewController:navigationController]; } } - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if(self.shouldRotate ) //shouldRotate is my flag { self.shouldRotate = NO; return (UIInterfaceOrientationMaskLandscapeRight); } return (UIInterfaceOrientationMaskPortrait); } 

并在我的视图控制器应该是风景和正在使用

  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { appDelegate.shouldRotate = YES; // Custom initialization } return self; } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

在我的viewcontrollers是potrait正在使用正确的

 - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

任何人都可以build议这样做

提前致谢

我发现只有rootviewcontroller处理这些事情在iOs 6.看看我的答案在这里: https ://stackoverflow.com/a/13033443/580173

这是为我工作,我删除了NavigationController和改变如下

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self.viewController = [[PlashViewController alloc] initWithNibName:@"PlashViewController" bundle:nil]; } self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; return YES; } 

即时通讯我的应用程序将这种方法放在我的视图控制器如下,在plist和目标我指定三个方向像肖像,landscapeleft和landscaperight 展示纵向

 -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 

在风景中展示风景

  - (BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }