0

我想呈現自定義大小的視圖控制器(500,500)。我試圖用下面的代碼來做到這一點,如果我單獨呈現視圖控制器,但是當我將視圖控制器放在導航控制器(我想要這樣做)中存在黑色背景時,它可以很好地與半透明淺灰色背景一起使用這出現了,我不想要這個,我想要灰色的。用導航呈現自定義大小的視圖控制器

我沒有這個問題的幫助下面的代碼:

iOS -- how do you control the size of a modal view controller?

MyViewController *vc=[[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil]; 

UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:vc]; 

nav.modalPresentationStyle=UIModalPresentationPageSheet; 

[self.window.rootViewController presentModalViewController:nav animated:YES]; 

CGRect r = CGRectMake(self.window.rootViewController.view.bounds.size.width/2 - 250, 
           self.window.rootViewController.view.bounds.size.height/2 - 250, 
           500, 500); 
r = [self.window.rootViewController.view convertRect:r toView:vc.view.superview.superview]; 
    vc.view.superview.superview.frame = r; 

任何猜測,我很想念這裏?還是有一種簡單的方法來顯示導航自定義大小的VC?

導航:

enter image description here

沒有導航:(我使用的是深色的背景,因此可能會出現像它是黑色的,但它不是) enter image description here

+0

什麼'vc.view.superview.superview.frame = r'呢? – Undo 2013-04-04 04:42:30

+0

將VC的幀分別縮小到其超視圖。 – satheeshwaran 2013-04-04 04:44:55

+0

什麼都可以? – satheeshwaran 2013-04-04 05:21:14

回答

2
+0

是的,我得到你,但事情是,我得到一個透明的視圖默認情況下,如果我提出一個ViewController對象和一個黑色的,當我用ViewController在其中展示NavigaitonContoller。爲什麼?? – satheeshwaran 2013-04-04 06:39:52

+0

我認爲這可能是因爲窗口顏色... – Venkat 2013-04-04 06:43:48

+0

沒有傢伙試過,不是因爲它。 – satheeshwaran 2013-04-04 06:45:33

相關問題