6

我正在使用splitviewcontroller作为我的应用程序的rootview。我需要将登录和注册视图显示为splitviewcontroller顶部的模式视图。当我尝试从splitViewController的rootview的viewdidAppear方法呈现登录/ reg视图时,它不显示。我尝试使用以下代码从Appdelegate的didFinishLaunching方法中提供登录/注册视图UISplitViewController和方向 - iOS <5.0

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

它工作。

我的问题是,应用程序同时支持横向方向,但是当我在设备中运行它时,无论在哪个方向上,我都拿着设备,我只获取LandscapeRight作为方向。因此,如果我将设备放在LandscapeLeft方向,则应用程序会与登录屏幕颠倒。我正在使用LandscapeLeft &正确支持info.plist上的方向。

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

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

+0

在登录屏幕的控制器中,您是否实现了' - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation'以获得您所需的两个方向? – 2012-01-07 04:53:22

+0

正确的方法应该来自您的splitViewController的viewDidAppear方法,您可以在iOS 5上使用它。您能否提供源代码以便我们看到它的外观?也许在那里可能会有不同的做法。 – 2012-01-19 23:23:47

回答

0

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

也IIRC,使用[[UIApplication sharedApplication] statusBarOrientation]绕过这个问题。

-1

从窗口中删除登录视图后,根据设备的方向使用以下代码设置rootviewcontroller的方向。

#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控制器。