简体   繁体   中英

Navigation Controller inside UIView

Whe I create a new UIViewController and try to put inside a NavigationController in the usual way (drag-drop in the xib and create the outlet), I show the Navigationcontroller with:

[self.view addSubview:navigationController.view]

The result is a Navigation Bar with a little band in the upper part (seems displaced down), (i can't post the image now but is like 20px empty space)

I tried to put the navigation controller on the top window:

[[[UIApplication sharedApplication] keyWindow] addSubview:navigationController.view];

And it worked, but I'm unable to come back the initial screen whe I execute:

[navigationController.view removeFromSuperview]

or

[self dissmissModalViewControllerAnimated:YES];

It is possible to solve this?

UINavigationController* nav=[[UINavigationController alloc]init];
nav.navigationBar.frame=CGRectMake(0, 0, 320, 44);
NSLog(@"desc=%@",[nav.navigationBar description]);
[self.view addSubview:nav.navigationBar];

Try with above code. it will hide unnecessary space. Thanks

20 pixels sounds like the status bar. Make sure in your nib that the status bar option for the view is set to None. Hope that Helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM