2012-01-11 81 views
0

Modalviewcontroller加載後顯示間隙。 Gap在移動了modalviewcontroller的staus bar之後,差距顯示了我的主窗口。所以我怎樣才能消除狀態欄和模態控制器之間顯示的這個差距。沒有介入構建器。以編程方式創建一切。幫助這將非常感激。modalviewcontroller加載後顯示間隙

UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight]; 

[button addTarget:self action:@selector(displayModalViewaction:) forControlEvents:UIControlEventTouchUpInside]; 

UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button]; 


    - (void)displayModalViewaction: (id) sender 
{ 

self.viewController = [[Infoviewcontroller alloc] init]; 

UINavigationController *navigationController=[[UINavigationController alloc] init]; 

navigationController.navigationBar.tintColor = [UIColor brownColor]; 

[navigationController pushViewController:_viewController animated:YES]; 

[self.view addSubview:navigationController.view]; 

    } 

感謝

+0

這段代碼在哪類中?它在UIViewController中嗎? – jaminguy 2012-01-11 16:35:25

+0

是的,它是一個UIViewController。找到desiredfullsizelayout,但這對於視圖應該與狀態欄重疊。 – user1120133 2012-01-11 16:39:59

+0

你需要發佈更多的代碼,以便我們可以看到你做錯了什麼。你的didFinishLaunchingWithOptions:實現看起來像什麼?在此之前有多少其他視圖控制器被創建,以及應用程序流是什麼樣的? – jaminguy 2012-01-11 20:10:41

回答

0

通過添加視圖幀大小[self.view setFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];修復了狀態欄和模態視圖之間的差距。

0

假設這個代碼是你可能想要做這樣的事情一個UIViewController。

self.viewController = [[[Infoviewcontroller alloc] init] autorelease]; 

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 

    navigationController.navigationBar.tintColor = [UIColor brownColor]; 

    [self presentModalViewController:navigationController animated:YES]; 

    [navigationController release]; 
+0

感謝您的幫助。我試過了,但它不起作用 – user1120133 2012-01-11 16:50:07

+0

通過添加視圖幀大小 [self.view setFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) ]。 修復了狀態欄和模態視圖之間的差距。 – user1120133 2012-01-11 21:41:22

1

在你_viewController,你需要的,如果你想隱藏的差距,更新此代碼 -

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; 

但最好它需要被固定副

[self presentModalViewController:navigationController animated:YES]; 

不知道爲什麼它不適合你。

相關問題