【问题标题】:Split UIWebView load and display in different threads拆分 UIWebView 在不同线程中加载和显示
【发布时间】:2012-08-17 07:36:45
【问题描述】:

UIWebView 是否可以加载本地 html 页面,然后在一个线程中运行 javascript,并在主线程中显示该页面?伪代码如下:

bool refresh;
WebView* webView;
void main() {
    newThreadStarts();
    while(true) {
        if (refresh) {
            webView->Refresh();
        }
        // a lot of other time-consuming code go here
        sleep(1000);
    }
}

void newThreadLoop() {
    webView->Load();
    while(true) {
        evaluateJavaScript();
        sleep(1000);
    }
}

ps:我是可可和 iPhone 开发的新手。

【问题讨论】:

    标签: iphone multithreading


    【解决方案1】:

    没有:(

    UIWebView 执行 javascript 的方式 - UIWebView stringByEvaluatingJavascriptFromString: - 必须在主线程上运行,否则您的应用将很快崩溃。

    这里有一个类似的问题:Can I run a UIWebView in a seperate thread?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 2017-12-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-28
      • 2023-03-06
      相关资源
      最近更新 更多