UIWebView scrolls jerkily

荒凉一梦 提交于 2019-12-09 13:54:47

问题


I need to use a website with quite a bit of content in my App via UIWebView.

When I scroll the page in Mobile Safari everything scrolls smoothly. Even if I scroll fast - the grey squared background appears but is rendered properly after a few moments (less then 0.5 seconds).

The same page in UIWebView scrolls jerkily if scrolled fast and doesn't show the grey squared background. I guess Mobile Safari shows the grey squared background first and renders after that while UIWebview stops the scrolling until the part which will be shown is rendered.

How to I tell UIWebView to behave like Mobile Safari?


回答1:


It is already being drawn on it's own custom tiledLayer. The problem is that it is by default attempting to draw itself on the main thread so it locks up when I can't be drawn. There is a private message you can call

-(void)_setDrawInWebThread:(BOOL)arg1

That will work BUT you will see empty space when you scroll too fast and it can't keep up with the drawing until it has time to catch up. They use:

-(void)_setDrawsCheckededPattern:(BOOL)arg1

in mobile safari to help with this.




回答2:


Found a better solution. CGTiledLayer. http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CATiledLayer_class/Introduction/Introduction.html



来源:https://stackoverflow.com/questions/1187168/uiwebview-scrolls-jerkily

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!