【问题标题】:UINavigationController view does not fill the screenUINavigationController 视图没有填满屏幕
【发布时间】:2011-04-11 05:47:27
【问题描述】:

当我使用 UINavigationController 并将其放在我的 cocos2d 视图之上(默认情况下一切都是横向的)时,它不会填满整个屏幕。尺寸基本上就好像它处于纵向模式一样。我花了好几个小时试图把它弄出来,这让我发疯了。有什么想法吗?

我只需要一个 uiviewcontroller 就可以让它工作,并通过将框架设置为全尺寸来查看。

UIView* view = [[CCDirector sharedDirector] openGLView];

    sssRootViewController *rooviewController = [[[sssRootViewController alloc]init]autorelease];

        [[CCDirector sharedDirector] pause];
    StarTravelAppDelegate *appDelegate = (StarTravelAppDelegate *)[[UIApplication sharedApplication] delegate];

    rooviewController.view.frame =  CGRectMake(0,0,480,320);

    UINavigationController *navcontrol = appDelegate.myNavController;

     UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rooviewController];
    navcontrol.view.frame = CGRectMake(0,0,480,320);
    [view addSubview:navigationController.view];

    navcontrol.wantsFullScreenLayout = true;
[view addSubview: navcontrol.view];

【问题讨论】:

    标签: iphone objective-c uikit cocos2d-iphone


    【解决方案1】:

    首先将一个 UIWindow 添加到您的应用程序,然后将导航控制器添加到该窗口。

    【讨论】:

      【解决方案2】:

      您可以尝试用这种方法调整导航栏的大小,

        - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
              // Overriden to allow any orientation.
              if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
                  // root view
                      self.view.frame = CGRectMake(0, 0, 480,320);    
                      self.navigationBar.frame= CGRectMake(0, 175, 480,44);               
      
              } else {
                  // root view
                  self.view.frame = CGRectMake(0, 0, 320,480);    
                  self.navigationBar.frame= CGRectMake(0, 175, 320,44);                           
              }
      
              return YES;
          }
      

      玩这个 希望这会有所帮助 祝你好运

      【讨论】:

      • 这个方法驻留在哪个类中?
      • 在您的视图控制器中,就像在您的 sssRootViewController 中一样
      【解决方案3】:

      您是否尝试将框架属性设置为

      [[UIScreen mainScreen] applicationFrame];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-02-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多