iOS: display modal view over the top of a UIWebView

Posted by Sly on Stack Overflow See other posts from Stack Overflow or by Sly
Published on 2010-12-23T06:47:23Z Indexed on 2010/12/23 6:54 UTC
Read the original article Hit count: 204

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...

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; 
}

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];    
    }   


}

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!

© Stack Overflow or respective owner

Related posts about ios

Related posts about uiwebview