2011-12-19 69 views
1

我是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]; 
} 

以下是輸出。

enter image description here

如果有人知道,請幫助我。提前致謝。

回答

1

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]; 
} 
+0

或者您必須像這樣設置navi.view的框架[navi.view setFrame:CGRectMake(0,0,320,480)]; – 2011-12-20 04:59:45

相關問題