我使用 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.
发布评论
评论(2)
如果我没记错的话,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.从窗口中删除登录视图后,使用以下代码根据设备的方向设置 rootviewcontroller 方向。
它将根据设备方向加载 Rootviewcontroller。
After removing the login view from the window set the rootviewcontroller direction according to the orientation of device using following code.
It will load the Rootviewcontroller according to the device orientation.