iPad + UIWebView + presentModalViewController

Posted

技术标签:

【中文标题】iPad + UIWebView + presentModalViewController【英文标题】: 【发布时间】:2011-09-23 11:05:34 【问题描述】:

我有一个非常基本的视图控制器类,通过界面生成器创建。它只有一个视图,即 UIWebView(参见此处:http://i55.tinypic.com/xdax01.png)。

在我的应用程序中,我想通过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];

应用程序将正确显示带有表单大小的模式对话框(不是全屏)。

我必须做什么才能以较小的表单尺寸而不是全屏显示我的视图控制器类?

【问题讨论】:

【参考方案1】:

modalPresentationStyle 适用于呈现的视图控制器而不是宿主视图控制器。所以在你的情况下,你必须这样做:


dvc.modalPresentationStyle=UIModalPresentationFormSheet;

【讨论】:

请标记为已回答...它增加了我的堆栈溢出声誉!

以上是关于iPad + UIWebView + presentModalViewController的主要内容,如果未能解决你的问题,请参考以下文章