iPhone UIWebView - Calling loadHTMLString:baseURL:

2019-05-21 00:36发布

Is the -loadHTMLString:baseURL: method of UIWebView meant to only be called once per instance?

Here's my logic flow:

1.  View loads & supplies UIWebView placeholder text via -loadHTMLString:baseURL:
2.  NSURLConnection requests a URL asynchronously
3.  Upon NSURLConnection finished, replace UIWebView content with loaded data 
    via -loadHTMLString:baseURL:

Debugging shows that loadHTMLString:baseURL: is being called and the string being passed in is correct, but the UIWebView isn't updated. I even tried calling [webViewInstance setNeedsDisplay] thinking a redraw would fix it, but no dice.

In Apple Developer docs, it says nothing about the method being one-call-per-instance, but based on its behavior, this is what it seems like. Anyone else run into this?

1条回答
趁早两清
2楼-- · 2019-05-21 01:13

There's no limit on the number of times loadHTMLString: can be called. I call it hundreds of times on the same UIWebView in my app.

Did you implement webView:shouldStartLoadWithRequest:navigationType: ? If you did, make sure you return YES.

查看更多
登录 后发表回答