如何提高UIWebView滚动性能? [英] Ways to improve UIWebView scrolling performance?

查看:116
本文介绍了如何提高UIWebView滚动性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个包含 UIWebView 的应用程序,其中包含大量图像,CSS,嵌入式视频和JavaScript点击处理程序。滚动表现很糟糕,我正在寻找有效改善这种情况的方法。

I am building an application that includes a UIWebView containing a large number of images, CSS, embedded video, and JavaScript tap handlers. Scrolling performance is stuttery and I am looking for insight into the most effective ways to improve this.

如果以下任何特征导致滞后 UIWebView 滚动?还有哪些其他因素可能阻碍表现?

Which if any of the following characteristics lead to laggy UIWebView scrolling? What other factors may be hindering performance?


  • 图像数量

    • 我应该是当用户滚过它们时从DOM中删除图像,如果它们向上滚动则将它们添加回去?


    • 网页视图中的Retina质量图像是否会比较小版本影响滚动性能?


    • 提前调整图像大小会产生很大的影响,而不是依赖于Web视图来根据<$ c $等声明进行扩展c>宽度:100%; ?

    • Would resizing the images ahead of time make a big difference, rather than relying on the web view to scale based on declarations like width: 100%;?

    • 我已经避免了 box-shadow ,但还有其他CSS属性,这些属性也会对滚动性能产生负面影响吗?

    • I have avoided box-shadow, but are there other CSS properties that are also known for adversely affecting scrolling performance?

    如果有任何其他资源或工具可用于分析,我很乐意听到它们。

    If there are any other resources or tools that can be used for profiling, I've love to hear about them.

    推荐答案

    这是我之前从Apple开发者技术支持获得的答案:

    This is the answer I got from Apple Developer Technical Support a while ago:


    At这次,我们没有提供任何优化UIWebView渲染的机制。
    您看到差异的原因是Mobile Safari和UIWebView没有使用相同的渲染引擎。

    At this time, we do not provide any mechanisms to optimize the rendering of UIWebView. The reason you see a difference is due to Mobile Safari and UIWebView not using the same rendering engine.

    性能取决于加载的内容。如果正在使用javascripts或使用插件,这可能会影响性能。

    The performance is dependent on the content loaded. If there are javascripts running or plugins being used, this can hinder the performance.

    我建议您在 http://developer.apple.com/bugreporter/ 详细说明了您的情况。这还可以让您了解错误报告的状态。

    I recommend that you file a bug report at http://developer.apple.com/bugreporter/ detailing your situation. This will also keep you informed on the status of your bug report.

    UIWebView的另一种可能替代方案是开源DTCoreText库: https://github.com/Cocoanetics/DTCoreText ,为Float Reader应用程序提供支持:http://itunes.apple.com/us/app/float-reader/id447992005?mt=8

    A possible alternative to UIWebView would be the open-source DTCoreText library: https://github.com/Cocoanetics/DTCoreText, which powers the Float Reader app: http://itunes.apple.com/us/app/float-reader/id447992005?mt=8

    这篇关于如何提高UIWebView滚动性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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