简体   繁体   English

如何提高UIWebView滚动性能?

[英]How to improve UIWebView scrolling performance?

It seems to be really hard to improve the performance of a UIWebView, especially for websites like Mashable or Ars Technica, where tons of scripts are loaded and long, multi-page articles are common. 似乎很难提高UIWebView的性能,特别是对于像Mashable或Ars Technica这样的网站,其中加载了大量脚本并且长篇多页文章很常见。

I'm aware of 3 similar questions, but they both have no working solution: 我知道3个类似的问题,但它们都没有可行的解决方案:

I wonder if there're any solutions to this problem. 我想知道这个问题是否有任何解决方案。 Any suggestions are welcome. 欢迎任何建议。

I'm afraid there isn't. 我担心没有。 Big websites remain big and hence consume lots of memory. 大网站仍然很大,因此消耗大量内存。

I'd argue against Brad Larson: backing a webview in a own CATiledLayer is technically possible (just do [webView.layer renderInContext: ] ) but does not make a lot of sense. 我反对Brad Larson:在自己的CATiledLayer中支持webview在技术上是可行的(只需要[webView.layer renderInContext: ] )但是没有多大意义。 Tiled layers load lazily, as do web views. 平铺层加载延迟,Web视图也是如此。 You'd need a enormous amount of finetuned code to detect when the page finished loading, then to cache things into your tiled layer and so on. 您需要大量精细的代码来检测页面何时完成加载,然后将内容缓存到您的平铺图层等等。

Despite that, the webview is actually quite optimized. 尽管如此,webview实际上已经非常优化了。 I'd even argue that it's one of the best-optimized things in the whole iOS. 我甚至认为它是整个iOS中最优化的东西之一。 It's the single-most-used performance critical component across the whole platform. 它是整个平台中最常用的性能关键组件。 Every multi-line text is a webview (UITextView is implemented using them, eg). 每个多行文本都是webview(UITextView是使用它们实现的,例如)。 If the webview breaks on some website, you'll have quite a hard time making it faster. 如果webview在某个网站上中断,你将很难加快速度。

There are cases where a different solution might work as well, but only if you're looking for something special purpose. 有些情况下,不同的解决方案也可以起作用,但前提是您正在寻找特殊目的。 If you're not, then leave your hands off and invest the time somewhere else. 如果你不是,那就离开你的手,把时间花在其他地方。 Just my 2 cent... 只是我的2美分......

I don't really know if this can help or is accurate given the question, but here is what I have to say: 鉴于这个问题,我真的不知道这是否有用或是否准确,但我要说的是:

Some properties like shadow or gradient, and even images inside the WebView affects a lot the performances you can get. 像阴影或渐变这样的属性,甚至WebView中的图像都会影响很多你可以获得的性能。 Try not to use them and/or to keep them as few as possible. 尽量不要使用它们和/或尽可能少地保留它们。

Some web browser applications like iCab and Atomic Web Browser seem to use the _setDrawInWebThread: method, and clearly they are allowed in the app store. 某些Web浏览器应用程序(如iCab和Atomic Web Browser)似乎使用了_setDrawInWebThread:方法,显然它们在应用商店中是允许的。 If they are not using this method, then they are using something that works identically to it for their UIWebViews. 如果他们没有使用这种方法,那么他们正在使用与UIWebViews相同的东西。 Does anyone know for sure Apple is rejecting apps that use this private API? 有没有人知道Apple拒绝使用这个私有API的应用程序? Could they be letting that one go by "silently"? 难道他们会“默默地”让那个人过去吗? I'm surprised Apple hasn't made this a public API by now, because any application that uses a UIWebView to display a web page (and there are many high profile apps that do this, FlipBoard for example) makes the device look 'choppy' and sub-par performing... 我很惊讶Apple现在还没有把它变成一个公共API,因为任何使用UIWebView来显示网页的应用程序(例如,有很多高调的应用程序都会这样做,例如FlipBoard)会使设备看起来“波涛汹涌” '和低于标准的......

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

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