如何在iOS应用程序中将uinavigationcontroller加载到uiviewcontroller
问题描述:
我是IOS开发中的新手。现在我实现了一个UINavigationController给UIViewController,但是这会给视图的顶部带来一个空隙。这是什么原因?以及如何避免这种差距?如何在iOS应用程序中将uinavigationcontroller加载到uiviewcontroller
这是我的代码
- (void)viewDidLoad
{
[self.view setBackgroundColor:[UIColor greenColor]];
SubClass *subClass=[[SubClass alloc]initWithNibName:@"SubClass" bundle:nil];
UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:subClass];
[self.view addSubview:navi.view];
[super viewDidLoad];
}
以下是输出。
如果有人知道,请帮助我。提前致谢。
答
U可以添加更多的线
[navi.view SETFRAME:[self.view界限]];
- (void)viewDidLoad
{
[self.view setBackgroundColor:[UIColor greenColor]];
SubClass *subClass=[[SubClass alloc]initWithNibName:@"SubClass" bundle:nil];
UINavigationController *navi=[[UINavigationController alloc]initWithRootViewController:subClass];
[navi.view setFrame: [self.view bounds]];
[self.view addSubview:navi.view];
[super viewDidLoad];
}
或者您必须像这样设置navi.view的框架[navi.view setFrame:CGRectMake(0,0,320,480)]; – 2011-12-20 04:59:45