我可以在单独的线程中运行UIWebView吗? [英] Can I run a UIWebView in a seperate thread?

查看:123
本文介绍了我可以在单独的线程中运行UIWebView吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行JavaScript应用程序的Web视图,有时当主线程执行xhr调用和初始化视频播放器等较重的工作时它会冻结/挂起。是否可以在单独的线程中运行UIWebView,以避免阻止Web视图?

I have a web-view running JavaScript application, and sometimes it freezes/hangs when the main thread are performing heavier jobs like xhr calls and initializing video player. Is it possible to run a UIWebView in a separate thread, to avoid the web-view from being blocked?

推荐答案

UIWebView 可以调用主线程中的 UIKit 。将它放在一个单独的线程中可能会导致崩溃。您无法在后台线程上创建视图,这是UI的内容。正如保罗在评论中所说的那样,你最好的办法是将主线程中的任何其他东西都移到自己的队列中。

UIWebView may make calls to UIKit which is in the main thread. Placing it in a separate thread will likely cause a crash. You can't create views on background threads, that's UI stuff. As Paul said in the comment, your best bet is to move anything else tying up the main thread into its own queue.

这篇关于我可以在单独的线程中运行UIWebView吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆