UINavigationController视图未填满屏幕

时间:2011-04-11 05:47:27

标签: iphone objective-c uikit cocos2d-iphone

当我使用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];

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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;
    }

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

答案 2 :(得分:0)

您是否尝试过将frame属性设置为

[[UIScreen mainScreen] applicationFrame];