2011-04-11 103 views
0

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

我能够得到这个只与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]; 

回答

0

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

+0

这不起作用 – Mel 2011-04-11 06:15:30

0

,你可以尝试调整您的导航栏在这种方法中,

本 希望
- (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; 
    } 

发挥,这将有助于 好运

+0

此方法驻留在哪个类? – Mel 2011-04-11 06:15:57

+0

在你的视图控制器像你的sssRootViewController – 2011-04-11 06:16:48

+0

这没有工作 – Mel 2011-04-11 21:57:43

0

您是否尝试过你的框架属性设置为

[[UIScreen mainScreen] applicationFrame]; 
+0

这没有工作 – Mel 2011-04-11 21:58:23