开发者

UINavigationController view does not fill the screen

When I use a UINavigationController and put it on top of my cocos2d view (everything is landscape by default) it doesn't fill the whole screen. The sizing is basically as if it was in portrait mode. I've spent hours trying to fgirue it out and it is driving me crazy. A开发者_C百科ny ideas?

I was able to get this to work with just a uiviewcontroller and view by setting the frame to the full size.

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];


First add an UIWindow to your application and then add the navigation controller to that window.


you can try to resize your navigation bar in this method ,

  - (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;
    }

play with this hope this will help good luck


Have you tried setting your frame property to

[[UIScreen mainScreen] applicationFrame];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜