UIWebView loadHTMLString shows blank screen

前端 未结 3 864
一向
一向 2021-02-07 04:52

I have a strange problem with UIWebView\'s loadHTMLString, where it would only display a blank view when I called loadHTMLString with my content HTML string. It does not matter

相关标签:
3条回答
  • 2021-02-07 04:54

    I just had the same problem, and being a n00b, i found myself surprised that the problem was solved when i DID NOT DO

    webview = [[UIWebView alloc]init];
    

    but instead, since it was already wired up as an outlet, i just had to call

    [webView loadHTMLString:mystring baseURL:nil];
    
    0 讨论(0)
  • 2021-02-07 05:04

    After a bit of detective work, I found out that returning NO in the delegate function

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    

    will reject loadHTMLString requests. Returning YES solved my problem.

    0 讨论(0)
  • 2021-02-07 05:09

    From your initialization code for the UIWebView, it looks like you're adding wcbbcPanel at a position that would be off the screen. Try this instead:

    wcbbcPanel = [[WarrantsAndCbbc alloc] initWithFrame:CGRectMake(0, 0, 320, 230)];
    
    0 讨论(0)
提交回复
热议问题