2011-09-22 62 views
0

當我調用這個方法時,導航欄顯示,並沒有正確放置。精確的導航欄從模擬器頂部的20像素放置。如何解決這個問題。我在子類之前調用​​這個方法。但下一頁導航欄放置不正確。導航欄顯示,但它沒有正確放置在iphone

UtilityController *object=[[UtilityController alloc]initWithNibName:@"UtilityController" bundle:nil]; 
navigationController=[[UINavigationController alloc] initWithRootViewController:object]; 
[self.view addSubview:navigationController.view]; 
[object release]; 

如何解決此方法。提前致謝。

+0

您是否隱藏頂部的狀態欄? :) –

+0

不,我沒有狀態欄。 –

+0

你爲什麼要添加子視圖?你可以用'[self presentModalViewController:navigationController]來呈現它;'試試這個 – Heena

回答

0

你應該設置你的navigationControllerframe屬性的適當的值,〔實施例:

navigationController.frame = CGRectMake(0, 0, 320, 460); 

也是最好的做法是將UINavigationController爲模態的視圖:

[self presentModalViewController:navigationController animated:YES]; 

新例子

UtilityController *object=[[UtilityController alloc]initWithNibName:@"UtilityController" bundle:nil]; 
navigationController=[[UINavigationController alloc] initWithRootViewController:object]; 
[self presentModalViewController:navigationController animated:YES]; 
[object release]; 
[navigationController release]; 
+0

如何使用上面的代碼調用這個方法。你可以給代碼請問 –

+0

更新我的回答 – Nekto

+0

UtilityController * object = [[UtilityController alloc] initWithNibName:@「UtilityController」bundle:nil]; [navigationController.frame = CGRectMake(0,0,320,460)initWithRootViewController:object]; [self.view addSubview:navigationController.view]; \t [object release]; 這段代碼是對的嗎? –

相關問題