2011-02-07 37 views
1

我正在使用MonoTouch,MonoDevelop和Interface Builder编写iPad应用程序,而且我偶然发现了一个似乎无法解决的问题。这可能很简单。我试图做的是从开始强制应用程序到Landscapemode。该应用程序在Landscape中开始,但不会正确调整子视图的大小。iPad风景无法正确调整子视图的正确尺寸

基本上我在我的appdelegate中做的是我添加一个叫做IndexViewController.xib的SubView到Window。在IndexViewController中,如果我在IndexViewController中重载ShouldAutorotateToInterfaceOrientation来返回它,它会有一个带有标签的视图:它工作正常。

public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) 
{ 
      return ((toInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientation.LandscapeRight)); 
} 

不过,我现在尝试创建一个NavigationController并将其添加到在初始化IndexController.xib视图:

void Initialize() 
    { 
     this.View.AddSubview (NavController.View); 
    } 

它正确地旋转,但没有填满整个“窗口” ,我发布了截图和示例解决方案。而我的info.plist设置为允许 “UIInterfaceOrientationLandscapeLeft” 和 “UIInterfaceOrientationLandscapeLeftRight” 为UISupportedInterfaceOrientations

Screenshot

Sample solution here

有可能是死的东西简约不简单,我很想念,但我无法弄清楚。

回答

2

我想说这可能是由于您建立应用程序层次结构的方式并不是建议的方式。虽然你可以继续这样做,但你会遇到更多的问题。 理想情况下,您希望添加NavigationController的View窗口,而不是将NavigationController包含在UIViewController中。

在应用程序的委托,我会做线沿线的东西:

IndexViewController indexVC = new IndexViewController() 
UINavigationController navController = new UINavigationController(indexVC); 
window.AddSubview(navController.View); 

这将导航控制器的视图添加到窗口,把NavigationControllerRootViewController是您IndexViewController

你还应该删除已添加到Initialise()中的IndexViewController中的UINavigationController

我刚刚下载了您的示例解决方案,并且非常快速地尝试了它,并将视图加载到横向视图中以充分填充屏幕。它没有自动旋转,但这肯定会是一个很好的起点:)

+0

感谢您的回答,解决了我的问题:) – degborta 2011-02-07 14:46:14

相关问题