iPhone UIWebView - Calling loadHTMLString:baseURL: a second time doesn't do anything?

霸气de小男生 提交于 2019-12-22 15:09:24

问题


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:


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.



来源:https://stackoverflow.com/questions/3086188/iphone-uiwebview-calling-loadhtmlstringbaseurl-a-second-time-doesnt-do-anyt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!