简体   繁体   English

iPhone UIWebView-调用loadHTMLString:baseURL:第二次不执行任何操作?

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

Is the -loadHTMLString:baseURL: method of UIWebView meant to only be called once per instance? UIWebView的-loadHTMLString:baseURL:方法是否每个实例只能调用一次?

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. 调试显示正在调用loadHTMLString:baseURL:并且传递的字符串正确,但是未更新UIWebView。 I even tried calling [webViewInstance setNeedsDisplay] thinking a redraw would fix it, but no dice. 我什至尝试调用[webViewInstance setNeedsDisplay],以为重绘可以解决该问题,但没有骰子。

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. 在Apple Developer文档中,它没有说该方法是“每实例一次调用”,而是基于其行为,这看起来像是。 Anyone else run into this? 还有其他人遇到吗?

There's no limit on the number of times loadHTMLString: can be called. 对于loadHTMLString:可以被调用的次数没有限制。 I call it hundreds of times on the same UIWebView in my app. 我在应用程序中的同一UIWebView上调用了数百次。

Did you implement webView:shouldStartLoadWithRequest:navigationType: ? 您是否实现了webView:shouldStartLoadWithRequest:navigationType :? If you did, make sure you return YES. 如果这样做,请确保返回YES。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM