Iphone 在不同线程中拆分UIWebView加载和显示
UIWebView是否可以加载本地html页面,然后在一个线程中运行javascript,然后在主线程中显示页面?伪代码如下:Iphone 在不同线程中拆分UIWebView加载和显示,iphone,multithreading,Iphone,Multithreading,UIWebView是否可以加载本地html页面,然后在一个线程中运行javascript,然后在主线程中显示页面?伪代码如下: bool refresh; WebView* webView; void main() { newThreadStarts(); while(true) { if (refresh) { webView->Refresh(); } // a lot of other time-
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开发的新手。不:(
UIWebView执行javascript-UIWebView stringByEvaluatingJavascriptFromString:-的方式必须在主线程上运行,否则您的应用程序将很快崩溃
这里有一个类似的问题: