UISplitViewController和方向 – iOS <5.0

我正在使用一个splitviewcontroller作为我的应用程序的rootview。 我需要将login和注册视图显示为splitviewcontroller上方的模式视图。 当我尝试从splitViewController的rootview的viewdidAppear方法呈现login/ reg视图,它不显示。 我尝试使用下面的代码从Appdelegate的didFinishLaunching方法呈现login/注册视图

[self.window.rootViewController presentModalViewController:self.navController animated:NO]; 

它的工作。

我的问题是,应用程序支持两个风景方向,但是当我在设备中运行它,无论在哪个方向我拿着设备,我只得到作为方向的LandscapeRight。 所以,如果我在LandscapeLeft方向持有该设备,应用程序与login屏幕颠倒。 我在info.plist上使用LandscapeLeft&Right支持方向。

请帮我解决这个问题。 当我们将splitViewcontroller作为应用程序的rootview时,我们将如何呈现视图?

在iOS 5.0(仅限于)中,我能够显示来自splitviewcontroller的rootview控制器 – viewdidAppear方法的login视图。 在所有其他操作系统版本中,这种情况不起作用,我需要从Appdelegate的didFinishLaunching方法中提出。

如果我没有记错,iOS会误报实际的方向直到第一次旋转

还有IIRC,使用[[UIApplication sharedApplication] statusBarOrientation]解决这个问题。

从窗口中删除login视图后,使用以下代码根据设备的方向设置rootview控制器的方向。

 #define DegreesToRadians(x) ((x) * M_PI / 180.0) [LoginviewContoller.view removeFromSuperview] self.viewController = [[[ExampleViewController alloc] initWithNibName:@"ExampleViewController" bundle:nil] autorelease]; switch(self.viewController.interfaceOrientation) { case UIInterfaceOrientationPortrait: NSLog(@"potrait"); break; case UIInterfaceOrientationPortraitUpsideDown: NSLog(@"prtraitdown"); break; case UIInterfaceOrientationLandscapeLeft: self.viewController.view.transform = CGAffineTransformMakeRotation(DegreesToRadians(270)); NSLog(@"lanscapelef"); break; case UIInterfaceOrientationLandscapeRight: self.viewController.view.transform = CGAffineTransformMakeRotation(DegreesToRadians(90)); NSLog(@"landcsape righ"); break; } [self.window addSubview:self.viewController.view]; 

它将根据设备方向加载Rootview控制器。