UISplitViewController 和方向 - iOS < 5.0

发布于 2024-12-25 03:20:37 字数 747 浏览 1 评论 0 原文

我使用 splitviewcontroller 作为我的应用程序的根视图。我需要将登录和注册视图显示为 splitviewcontroller 顶部的模式视图。当我尝试从 splitViewController 的 rootview 的 viewdidAppear 方法呈现登录/注册视图时,它没有显示。我尝试使用以下代码从 Appdelegate 的 didFinishLaunching 方法中呈现登录/注册视图,

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

并且它有效。

我的问题是,该应用程序支持横向方向,但是当我在设备中运行它时,无论我以哪个方向握住设备,我都只得到 LandscapeRight 作为方向。因此,如果我将设备保持在 LandscapeLeft 方向,应用程序就会启动,登录屏幕会颠倒。我正在使用 LandscapeLeft &就在 info.plist 上支持的方向上。

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

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

I am using a splitviewcontroller as the rootview of my application. I need to show the login and registration views as a modal view on top of the splitviewcontroller. When i try presenting login/reg view from the viewdidAppear method of splitViewController's rootview, it is not showing up. I tried presenting the login/reg view from the Appdelegate's didFinishLaunching method using the following code

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

and it works.

My problem is, the application supports both the landscape orientations, but when i run it in the device, no matter in which orientation i hold the device, I get only LandscapeRight as orientation. So if i hold the device in LandscapeLeft orientation, app lauches with login screen upside down. I am using LandscapeLeft & Right in supported orientations on the info.plist.

Please help me resolve the issue. Also how will we present a view when we have splitViewcontroller as the rootview of the app?

In iOS 5.0 (only) I am able to present the login view from the splitviewcontroller's rootview controller - viewdidAppear method. In all other OS versions, this case is not working and i need to present it from the Appdelegate's didFinishLaunching method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小霸王臭丫头 2025-01-01 03:20:37

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

此外,IIRC 使用 [[UIApplication sharedApplication] statusBarOrientation] 可以避免此问题。

If I remember correctly, iOS misreports the actual orientation until the first rotation.

Also IIRC, using [[UIApplication sharedApplication] statusBarOrientation] circumvents this problem.

空心空情空意 2025-01-01 03:20:37

从窗口中删除登录视图后,使用以下代码根据设备的方向设置 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];

它将根据设备方向加载 Rootviewcontroller。

After removing the login view from the window set the rootviewcontroller direction according to the orientation of device using following code.

#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];

It will load the Rootviewcontroller according to the device orientation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文