是否可以在UIWebView的顶部显示模式视图?我有一个加载WebView的UIViewController。然后,我想将Modal View Controller推到顶部,以使Modal View暂时覆盖WebView。

WebView运行正常;这是它在视图控制器中的加载方式:

- (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中加载模态视图控制器,则不会出现模态视图:
- (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顶部的视图。

感谢您事先的任何想法!

最佳答案

我遇到了同样的问题。将presentModalViewController调用从viewDidLoad移到viewDidAppear可以解决问题。

10-01 16:26
查看更多