2011-09-23 75 views
2

我有一個非常基本的視圖控制器類,通過接口生成器創建。它只有一個視圖,這是一個UIWebView(請參閱:http://i55.tinypic.com/xdax01.png)。iPad + UIWebView + presentModalViewController

在我的應用程序中的某個地方,我想通過presentModalViewController打開此視圖控制器作爲模式對話框。這是我的代碼來實現這一目標:

self.viewController.modalPresentationStyle= UIModalPresentationFormSheet; 

WebController* dvc= [[WebController alloc] initWithNibName:@"WebController" bundle:nil]; 

[self.viewController presentModalViewController:dvc animated:YES]; 

顯示的模態對話框,但不幸的是全屏顯示,而不是UIModalPresentationFormSheet的更小的尺寸。當我與這一個替換上面的代碼:

self.viewController.modalPresentationStyle= UIModalPresentationFormSheet; 

MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init]; 

[self.viewController presentModalViewController:mailViewController animated:YES]; 

該應用程序將正確地示出了具有形式的紙張尺寸(未全屏)模態對話框。

爲了在較小的表單大小而不是全屏下呈現我的視圖控制器類,我需要做些什麼?

回答

4

modalPresentationStyle適用於呈現的視圖控制器而不適用於託管視圖控制器。所以在你的情況下,你必須這樣做:


dvc.modalPresentationStyle=UIModalPresentationFormSheet; 
+0

非常感謝,作品像一個魅力! – user944943

+0

請標記爲已回答...它會增加我的堆棧溢出聲譽! – viggio24