简体   繁体   English

UIView内的导航控制器

[英]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: 当我创建一个新的UIViewController并尝试以常规方式放入NavigationController时(将其拖放到xib中并创建插座),我将向Navigationcontroller显示以下内容:

[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) 结果是导航栏的上部有一个小条带(似乎向下移动了),(我现在不能发布图像,但是就像20px的空白空间一样)

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. 20像素听起来像状态栏。 Make sure in your nib that the status bar option for the view is set to None. 确保在笔尖中将视图的状态栏选项设置为“无”。 Hope that Helps! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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