iOS:在UIWebView的顶部显示模式视图 [英] iOS: display modal view over the top of a UIWebView
问题描述
是否可以在UIWebView的顶部显示模式视图?我有一个加载WebView的UIViewController.然后,我想将Modal View Controller推到顶部,以使模式视图暂时覆盖WebView ...
Is it possible to display a modal view over the top of a UIWebView? I have a UIViewController that loads a WebView. I then want to push a Modal View Controller over the top so that a modal view covers up the WebView temporarily...
WebView运行正常;这是它在视图控制器中的加载方式:
The WebView is working fine; here's how it's loaded in the View Controller:
- (void)loadView {
// Initialize webview and add as a subview to LandscapeController's view
myWebView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
myWebView.scalesPageToFit = YES;
myWebView.autoresizesSubviews = YES;
myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
myWebView.delegate = self;
self.view = myWebView;
}
但是,如果我尝试从viewDidLoad中加载模态视图控制器,则不会出现模态视图:
If I attempt to load a Modal View controller from within viewDidLoad, however, no modal view appears:
- (void)viewDidLoad {
[super viewDidLoad];
// Edit dcftable.html with updated figures
NSMutableString *updated_html = [self _updateHTML:@"dcftable"];
// Load altered HTML file as an NSURL request
[self.myWebView loadHTMLString:updated_html baseURL:nil];
// If user hasn't paid for dcftable, then invoke the covering modal view
if (some_condition) {
LandscapeCoverController *landscapeCoverController = [[[LandscapeCoverController alloc] init] autorelease ];
[self presentModalViewController:landscapeCoverController animated:YES];
}
}
我怀疑UIWebView委托需要做一些事情才能使其接收新的模态视图...但是在任何地方都找不到任何讨论或示例...同样,目标是调用覆盖WebView顶部的模式视图.
I suspect that there's something that needs to be done with the UIWebView delegate to get it to receive the new modal view...but can't find any discussion or examples of this anywhere...again, the objective is to invoke a modal view that covers over the top of the WebView.
感谢您的任何事先的想法!
Thanks for any thoughts in advance!
推荐答案
我遇到了同样的问题.将presentModalViewController
调用从viewDidLoad
移到viewDidAppear
可以解决问题.
I ran into this same problem. Moving the presentModalViewController
call from viewDidLoad
to viewDidAppear
did the trick.
这篇关于iOS:在UIWebView的顶部显示模式视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!